package com.store.app.net;

import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;
import android.text.TextUtils;
import android.util.Log;

import com.google.gson.Gson;
import com.store.app.LocationApplication;
import com.store.app.MainActivity;
import com.store.app.bean.BookedBean;
import com.store.app.bean.ShoppingInfo;
import com.store.app.bean.WypGoodsBean;
import com.store.app.http.Stores;
import com.store.app.net.ifc.IOnHttpListener;
import com.store.app.utils.DateUtil;
import com.store.app.utils.IDUtil;
import com.store.app.utils.MoneyUtil;
import com.store.app.utils.SettingData;
import com.store.app.utils.TestDeviveInfo;
import com.store.app.utils.ToastUtils;
import com.store.app.utils.Utils;
import com.store.app.utils.http.MD5;

import net.tsz.afinal.http.AjaxParams;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.InputStream;
import java.text.Collator;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2016/1/18.
 * 所有的网络请求类
 */
public class NetRequest {
    private Context context;
    private IOnHttpListener listener;   //网络回调接口
    private BaseHttpRequest request;    //网络请求的基类

    public NetRequest(Context context) {
        this.context = context;
        Log.v("zyl", "NetRequest onCreate");
        this.listener = (IOnHttpListener) context;//传递过来的页面只要实现了IOnHttpListener接口，就可以作为回调的接受对象
        request = new BaseHttpRequest(context);
        request.setHttpListener(listener);
    }

    public NetRequest(IOnHttpListener listener, Context context) {
        this.context = context;
        this.listener = listener;//传递过来的页面只要实现了IOnHttpListener接口，就可以作为回调的接受对象
        request = new BaseHttpRequest(context);
        request.setHttpListener(listener);
    }

    public void requestCheckVersion(int requestId) {
        AjaxParams params = new AjaxParams();
        params.put("package_name", "com.store.app");
        requestData("/openapi/version/latest", requestId, params);
    }

    /**
     * @param requestId    网络请求id，用于区分同个页面的不同网络请求
     * @param ifShowDialog 是否显示提示框
     */
    public void requestData(String serviceAction, int requestId, boolean ifShowDialog, AjaxParams params) {
        request.requestData(serviceAction, requestId, ifShowDialog, params);
    }

    public void requestData(String serviceAction, int requestId, AjaxParams params) {
        request.requestData(serviceAction, requestId, false, params);
    }

    public void requestDataUploadPic(int requestId, AjaxParams params) {
        request.uploadPic(requestId, params);
    }

    /**
     * 意见反馈
     *
     * @param docIds    图片ids
     * @param number    联系方式
     * @param content   意见内容
     */
    public void requestFeedBack(int requestId, String docIds, String number, String content) {
        AjaxParams params = new AjaxParams();
        params.put("attchment", docIds);
        params.put("category", "bindbank");
        params.put("contact", number);
        params.put("data_source", "SJLY_02");
        params.put("desc1", content);
        params.put("user_token", MainActivity.user_token);
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/user/feedback", requestId, params);
    }

    public void queryToken() {
        if (TextUtils.isEmpty(MainActivity.app_token)) {
            SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
            MainActivity.app_token = preferences.getString("app_token", "");
        }
    }

//    /**
//     * 满多少送多少券
//     *
//     * @param requestId
//     * @param rw        满多少元
//     * @param rwData    送多少券
//     */
//    public void reuestReward(int requestId, int rw, int rwData, String status) {
//        AjaxParams params = new AjaxParams();
//        params.put("user_token", MainActivity.user_token);
//        JSONObject paramsone = new JSONObject();
//        try {
//            paramsone.put("activity", "reward");
//            paramsone.put("member_id", MainActivity.member_id);
//            paramsone.put("status", status);
//            paramsone.put("amount", rw + "");
//            paramsone.put("promotion", rwData + "");
//            paramsone.put("remark", "送");
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//        params.put("params", paramsone.toString());
//        params.put("service", "member.storeActivityPaymentEdit");
//        params.put("sign", genPackageSignUser(params));
//        requestData("/openapi/member", requestId, params);
//    }

    /**
     * 查询店东周围的消费者
     */
    public void requestGetRelConsumerList(int requestId, String memberId) {
        AjaxParams params = new AjaxParams();
        params.put("app_token", MainActivity.app_token);
        JSONObject paramsone = new JSONObject();
        try {
            paramsone.put("stores_id", memberId);
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (paramsone.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsone.toString());
        params.put("service", "member.storesRelConsumerList");
        params.put("sign", genPackageSign(params));
        requestData("/openapi/member", requestId, params);
    }

    /**
     * 查询是否绑定淘宝
     */
    public void requestQueryTaoBao(int requestId, String member_id,String member_type_key) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject paramsone = new JSONObject();
        try {
            paramsone.put("member_id", member_id);
            paramsone.put("member_type_key", member_type_key);
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (paramsone.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsone.toString());
        params.put("service", "memberExternalAccount.app.memberExternalAccountListFind");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/member", requestId, params);
    }

    public void requestBindTaoBao(int requestId, String user_id,String mobile,String member_type_key,String member_id,String account_type_key,String account_no) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject paramsone = new JSONObject();
        try {
            paramsone.put("user_id", user_id);
            paramsone.put("mobile", mobile);
            paramsone.put("member_type_key", member_type_key);
            paramsone.put("member_id", member_id);
            paramsone.put("account_type_key", account_type_key);
            paramsone.put("account_no", account_no);
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (paramsone.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsone.toString());
        params.put("service", "memberExternalAccount.app.memberExternalAccountCreate");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/member", requestId, params);
    }

//    memberExternalAccount.app.memberExternalAccountEdit
//    参数"account_id", "account_type_key", "account_no", "user_id","mobile", "member_id", "member_type_key"

    /**
     * 编辑淘宝账号
     *
     * @param account_id       绑定的淘宝账户id，淘宝账户的唯一标识
     * @param account_type_key 绑定的账户类型，目前只支持淘宝 写死taobao
     * @param account_no       绑定的淘宝账户名
     * @param mobile           手机号
     * @param member_type_key  会员类型，包括店东和消费者
     */
    public void requestEditTaoBao(int requestId, String account_id,String account_type_key,String account_no,String user_id,String mobile,String member_id,String member_type_key) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject paramsone = new JSONObject();
        try {
            paramsone.put("account_id", account_id);
            paramsone.put("account_type_key", account_type_key);
            paramsone.put("account_no", account_no);
            paramsone.put("user_id", user_id);
            paramsone.put("mobile", mobile);
            paramsone.put("member_id", member_id);
            paramsone.put("member_type_key", member_type_key);
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (paramsone.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsone.toString());
        params.put("service", "memberExternalAccount.app.memberExternalAccountEdit");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/member", requestId, params);
    }

    /**
     * 我要批订单详情
     */
    public void requestwypOrderItemForStoresFind(int requestId, String order_id) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject paramsone = new JSONObject();
        try {
            paramsone.put("order_id", order_id);

        } catch (Exception e) {
            e.printStackTrace();
        }

        if (paramsone.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsone.toString());
        params.put("service", "order.wypOrderItemForStoresFind");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/opsorder", requestId, params);
    }


    /**
     * 批量发放优惠券接口
     *
     * @param item_id   优惠券id
     * @param member_id 会员id
     */
    public void requestBatchHandoutCoupon(int requestId, String item_id, String member_id) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject paramsone = new JSONObject();
        try {
            paramsone.put("item_id", item_id);
            paramsone.put("member_id", member_id);
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (paramsone.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsone.toString());
        params.put("service", "goods.batchHandoutCoupon");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/goods", requestId, params);
    }

    /**
     * 通过商品id查询商品信息
     */
    public void requestQueryGoodsInfo(int requestId, String goods_id) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject paramsone = new JSONObject();
        try {
            paramsone.put("goods_id", goods_id);
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (paramsone.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsone.toString());
        params.put("service", "goods.wypGoodsDetailFind");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/goods", requestId, params);
    }

    /**
     * 通过供应商id查询促销规则
     */
    public void requestSupplierListPromotionFind(int requestId, String supplier_id) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject paramsone = new JSONObject();
        try {
            paramsone.put("supplier_id", supplier_id);
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (paramsone.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsone.toString());
        params.put("service", "member.supplierListPromotionFind");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/member", requestId, params);
    }

    /**
     * 新申请的导购列表
     */
    public void requestSaleAssistantAppliedForStoresListPageFind(int requestId, String page_no, String page_size) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject paramsone = new JSONObject();
        try {
            paramsone.put("stores_id", MainActivity.member_id);
        } catch (Exception e) {
            e.printStackTrace();
        }

        JSONObject pageObj = new JSONObject();
        try {
            pageObj.put("page_no", page_no + "");
            pageObj.put("page_size", page_size);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        if (paramsone.toString().equals("{}")) {
            return;
        }
        params.put("page", pageObj.toString());
        params.put("params", paramsone.toString());
        params.put("service", "saleAssistant.stores.saleAssistantAppliedForStoresListPageFind");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/member", requestId, params);
    }

    public void requestSaleAssistantAppliedForStoresListPageFind(int requestId) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject paramsone = new JSONObject();
        try {
            paramsone.put("stores_id", MainActivity.member_id);
        } catch (Exception e) {
            e.printStackTrace();
        }

        if (paramsone.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsone.toString());
        params.put("service", "saleAssistant.stores.saleAssistantAppliedForStoresListPageFind");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/member", requestId, params);
    }

    /**
     * 已批准的导购列表
     */
    public void requestSaleAssistantApprovedForStoresListPageFind(int requestId, String page_no, String page_size) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject paramsone = new JSONObject();
        try {
            paramsone.put("stores_id", MainActivity.member_id);
        } catch (Exception e) {
            e.printStackTrace();
        }

        JSONObject pageObj = new JSONObject();
        try {
            pageObj.put("page_no", page_no + "");
            pageObj.put("page_size", page_size);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        if (paramsone.toString().equals("{}")) {
            return;
        }
        params.put("page", pageObj.toString());
        params.put("params", paramsone.toString());
        params.put("service", "saleAssistant.stores.saleAssistantApprovedForStoresListPageFind");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/member", requestId, params);
    }

    /**
     * 批准社区导购申请
     */
    public void requestSaleAssistantApprove(int requestId, String consumer_id, String consumer_mobile, String stores_id, String stores_name) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject paramsone = new JSONObject();
        try {
            paramsone.put("consumer_id", consumer_id);
            paramsone.put("consumer_mobile", consumer_mobile);
            paramsone.put("stores_id", stores_id);
            paramsone.put("stores_name", stores_name);
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (paramsone.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsone.toString());
        params.put("service", "saleAssistant.stores.saleAssistantApprove");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/member", requestId, params);
    }

    /**
     * 邀请会员成为社区导购
     */
    public void requestSaleAssistantInvite(int requestId, String consumer_id, String consumer_mobile, String stores_id, String stores_name) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject paramsone = new JSONObject();
        try {
            paramsone.put("consumer_id", consumer_id);
            paramsone.put("consumer_mobile", consumer_mobile);
            paramsone.put("stores_id", stores_id);
            paramsone.put("stores_name", stores_name);
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (paramsone.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsone.toString());
        params.put("service", "saleAssistant.stores.saleAssistantInvite");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/member", requestId, params);
    }

    /**
     * 拒绝社区导购申请
     */
    public void requestSaleAssistantReject(int requestId, String consumer_id, String consumer_mobile, String stores_id, String stores_name) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject paramsone = new JSONObject();
        try {
            paramsone.put("consumer_id", consumer_id);
            paramsone.put("consumer_mobile", consumer_mobile);
            paramsone.put("stores_id", stores_id);
            paramsone.put("stores_name", stores_name);
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (paramsone.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsone.toString());
        params.put("service", "saleAssistant.stores.saleAssistantReject");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/member", requestId, params);
    }

    /**
     * 删除社区导购
     */
    public void requestDeleteGuide(int requestId, String consumer_id, String consumer_mobile, String stores_id, String stores_name) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject paramsone = new JSONObject();
        try {
            paramsone.put("consumer_id", consumer_id);
            paramsone.put("consumer_mobile", consumer_mobile);
            paramsone.put("stores_id", stores_id);
            paramsone.put("stores_name", stores_name);
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (paramsone.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsone.toString());
        params.put("service", "saleAssistant.stores.saleAssistantForStoresCancel");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/member", requestId, params);
    }

    /**
     * 社区导购历史记录
     */
    public void requestSaleAssistantHistoryPageFind(int requestId, String page_no, String page_size) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject paramsone = new JSONObject();
        try {
            paramsone.put("member_id", MainActivity.member_id);
            paramsone.put("member_type_key", "stores");
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (paramsone.toString().equals("{}")) {
            return;
        }
        if(!"0".equals(page_no)) {
            JSONObject pageObj = new JSONObject();
            try {
                pageObj.put("page_no", page_no + "");
                pageObj.put("page_size", page_size);
            } catch (JSONException e) {
                e.printStackTrace();
            }
            params.put("page", pageObj.toString());
        }
        params.put("params", paramsone.toString());
        params.put("service", "saleAssistant.member.saleAssistantHistoryPageFind");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/member", requestId, params);
    }

    /**
     * 礼券兑换历史记录
     */
    public void requestCoupleExchageHistoryPageFind(int requestId, String page_no, String page_size) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject paramsone = new JSONObject();
        try {
            paramsone.put("stores_id", MainActivity.member_id);
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (paramsone.toString().equals("{}")) {
            return;
        }
        JSONObject pageObj = new JSONObject();
        try {
            pageObj.put("page_no", page_no + "");
            pageObj.put("page_size", page_size);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        params.put("page", pageObj.toString());
        params.put("params", paramsone.toString());
        params.put("service", "voucher.stores.voucherExchangeLogPageFind");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/finance", requestId, params);
    }

    /**
     * 金币兑换现金
     */
    public void requestGoldExchangeCash(int requestId, String gold, String mobile) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject paramsone = new JSONObject();
        try {
            paramsone.put("data_source", SettingData.DATA_SOURCE);
            paramsone.put("member_id", MainActivity.member_id);
            paramsone.put("member_type_key", "stores");
            paramsone.put("mobile", mobile);
            paramsone.put("gold", gold);
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (paramsone.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsone.toString());
        params.put("service", "finance.goldExchangeCash");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/finance", requestId, params);
    }

    /**
     * 我要批创建订单(提交订单)
     */
    public void requestWypOrderCreate(int requestId, List<ShoppingInfo> shoppingInfoList) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject paramsone = new JSONObject();
        try {
            paramsone.put("member_id", MainActivity.member_id);
            paramsone.put("member_type_key", "stores");
            paramsone.put("stores_name", Stores.stores_name);
            paramsone.put("contact_person", Stores.contact_person);
            paramsone.put("contact_tel", Stores.contact_tel);
            paramsone.put("delivery_address", Stores.area_desc + Stores.address);
//            paramsone.put("delivery_fee",delivery_fee);
            //存放订单列表
            JSONArray jsonArray = new JSONArray();

            for (int i = 0; i < shoppingInfoList.size(); i++) {
                ShoppingInfo shoppingInfo = shoppingInfoList.get(i);
                //每笔订单发jsonObect 对象
                JSONObject jsonObject = new JSONObject();
                jsonObject.put("desc1", shoppingInfo.getBookedBeanList().get(0).getTitle());
                jsonObject.put("item_num", shoppingInfo.getBookedBeanList().size());
                //存放商品列表,里面每个商品是一个对象{}
                JSONArray goodsArray = new JSONArray();
                String sale_fee = "0.0";
                for (int j = 0; j < shoppingInfo.getBookedBeanList().size(); j++) {
                    JSONObject goodsObj = new JSONObject();
                    WypGoodsBean wypGoodsBean = shoppingInfo.getBookedBeanList().get(j);
                    goodsObj.put("goods_id", wypGoodsBean.getGoods_id());
                    goodsObj.put("goods_title", wypGoodsBean.getTitle());
                    goodsObj.put("goods_stock_id", wypGoodsBean.getSpecificationsBeanList().get(wypGoodsBean.getChooseIndexSpeci()).getGoods_stock_id());
                    goodsObj.put("sku", wypGoodsBean.getSpecificationsBeanList().get(wypGoodsBean.getChooseIndexSpeci()).getSku());
                    goodsObj.put("sku_desc1", wypGoodsBean.getSpecificationsBeanList().get(wypGoodsBean.getChooseIndexSpeci()).getDesc1());
//                    goodsObj.put("sku_desc1",wypGoodsBean.getDesc1());
                    Log.v("zyl", "wypGoodsBean.getDesc1():" + wypGoodsBean.getDesc1());
                    Log.v("zyl", "wypGoodsBean.getDesc1():" + wypGoodsBean.getSpecificationsBeanList().get(wypGoodsBean.getChooseIndexSpeci()).getDesc1());

                    goodsObj.put("discount_fee", wypGoodsBean.getLastMoney());//优惠后的价格，因为现在没优惠，所以等于sale_price
                    goodsObj.put("sale_price", wypGoodsBean.getLastMoney());
                    goodsObj.put("qty", wypGoodsBean.getBuyCount() + "");
                    goodsObj.put("total_fee", MoneyUtil.moneyMul(wypGoodsBean.getBuyCount() + "", wypGoodsBean.getLastMoney()));
                    goodsArray.put(goodsObj);
                    sale_fee = MoneyUtil.moneyAdd(sale_fee, MoneyUtil.moneyMul(wypGoodsBean.getBuyCount() + "", wypGoodsBean.getLastMoney()));
                }
                jsonObject.put("wyp_goods_list", goodsArray.toString());
                //去除商品列表优惠前的小计
                jsonObject.put("sale_fee", sale_fee);
                //优惠信息（调接口获取值后判断是否满足小计后得到的值）
                jsonObject.put("discount_fee", shoppingInfo.getDiscount_fee());

                String delivery_fee = "0";
                if (!MoneyUtil.moneyComp(sale_fee, shoppingInfo.getStarting_price())) {
                    delivery_fee = shoppingInfo.getShipping_fee();
                } else {
                    delivery_fee = "0";
                }

                jsonObject.put("total_fee", MoneyUtil.moneySub(MoneyUtil.moneyAdd(sale_fee, delivery_fee), shoppingInfo.getDiscount_fee()));
                jsonObject.put("delivery_fee", delivery_fee);
                jsonObject.put("supplier_id", shoppingInfo.getSupplierId());
                Log.v("zyl", "supplier:" + shoppingInfo.getSupplierName());
                jsonObject.put("supplier", shoppingInfo.getSupplierName());
                jsonObject.put("warehouse_id", shoppingInfo.getWarehouse_id());
                jsonObject.put("warehouse", shoppingInfo.getWarehouse());
                jsonArray.put(jsonObject);
            }
            paramsone.put("order_list", jsonArray.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (paramsone.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsone.toString());
        params.put("service", "order.wypOrderCreate");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/opsorder", requestId, params);
    }

    /**
     * 通过订单id查询支付信息
     */
    public void requestWypOrderPayFind(int requestId, String order_id) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject paramsone = new JSONObject();
        try {
            paramsone.put("order_id", order_id);
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (paramsone.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsone.toString());
        params.put("service", "order.wypOrderPayInfoFind");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/opsorder", requestId, params);
    }

    /**
     * 我要批订单支付
     */
    public void requestWypOrderPay(int requestId, Map map, String payment_way_key) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        map.put("data_source", "SJLY_02");
        map.put("payment_way_key", payment_way_key);
        params.put("params", Utils.mapToJson(map));
        params.put("service", "finance.wypOrderPay");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/finance", requestId, params);
    }


    /**
     * 赠送礼券
     *
     * @param phoneNumber 手机号
     * @param coupon      赠送礼券数量
     */
    public void requestSendCoupon(int requestId, String phoneNumber, String coupon) {
        if (TextUtils.isEmpty(MainActivity.member_id)) {
            ToastUtils.showTextToast(context, "店东id缺失,请重新登录！");
            return;
        }
        if (TextUtils.isEmpty(MainActivity.app_token)) {
            ToastUtils.showTextToast(context, "登录信息已失效,请重新登录");
            return;
        }
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject paramsone = new JSONObject();
        try {
            paramsone.put("data_source", "SJLY_02");
            paramsone.put("payment_way_key", SettingData.PAYMENT_WAY_06);
            paramsone.put("detail", "店东赠送");
            paramsone.put("amount", coupon + "");
            paramsone.put("out_trade_no", IDUtil.getOutTradeNo());
            paramsone.put("buyer_mobile", phoneNumber);
            paramsone.put("seller_id", MainActivity.member_id);
            paramsone.put("out_trade_body", paramsone.toString());
        } catch (Exception e) {
            e.printStackTrace();
        }
        if (paramsone.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsone.toString());
        params.put("service", "finance.voucherRewardByMobile");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/finance", requestId, params);
    }

    /**
     * 验证会员身份
     *
     * @param mobile 手机号
     */
    public void requestValidStoreExist(int requestId, String app_token, String mobile) {
        AjaxParams params = new AjaxParams();
        params.put("app_token", app_token);
        params.put("mobile", mobile);
        params.put("sign", genPackageSign(params));
        requestData("/openapi/user/valid_store_exist", requestId, params);
    }


    /**
     * 扫出C端条形码或者二维码拿到交易号进行验证，验证成功拿到信息
     */
    public void requestTradeCodeVerify(int requestId, String security_code) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject paramsone = new JSONObject();
        try {
            paramsone.put("security_code", security_code);
        } catch (JSONException e) {

        }
        params.put("service", "trade.tradeCodeVerify");
        params.put("params", paramsone.toString());
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/finance", requestId, params);
    }

    /**
     * 判断会员是否存在
     */
    public void requestVailsMemberExist(int requestId, String mobile) {
        AjaxParams params = new AjaxParams();
        params.put("app_token", MainActivity.app_token);
        JSONObject paramsone = new JSONObject();
        try {
            paramsone.put("mobile", mobile);
            paramsone.put("member_type_key", "consumer");
        } catch (JSONException e) {

        }

        if (paramsone.toString().equals("{}")) {
            return;
        }
        params.put("service", "member.memberInfoFindByMobile");
        params.put("params", paramsone.toString());
        params.put("sign", genPackageSign(params));
        requestData("/openapi/member", requestId, params);
    }

    /**
     * 查询礼券余额
     */
    public void requestQueryCoupleBalance(int requestId, String mobile) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject paramsone = new JSONObject();
        try {
            paramsone.put("mobile", mobile);
        } catch (JSONException e) {

        }
        if (paramsone.toString().equals("{}")) {
            return;
        }
        params.put("service", "voucher.app.voucherBalanceFind");
        params.put("params", paramsone.toString());
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/finance", requestId, params);
    }

    /**
     * 礼券兑换
     */
    public void requestVoucherExchange(int requestId, String consumer_id, String mobile, String voucher, String sms_code) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject paramsone = new JSONObject();
        try {
            paramsone.put("consumer_id", consumer_id);
            paramsone.put("mobile", mobile);
            paramsone.put("voucher", voucher);
            paramsone.put("sms_code", sms_code);
            paramsone.put("stores_id", MainActivity.member_id);
            paramsone.put("stores_name", Stores.stores_name);
        } catch (JSONException e) {

        }
        if (paramsone.toString().equals("{}")) {
            return;
        }
        params.put("service", "voucher.app.voucherExchange");
        params.put("params", paramsone.toString());
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/finance", requestId, params);
    }

    /**
     * 通过条形码查询商品是否标准商品
     */
    public void requestItemFind(int requestId, String barcode) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        params.put("service", "goods.itemFind");
        JSONObject paramsone = new JSONObject();
        try {
            paramsone.put("barcode", barcode);
        } catch (JSONException e) {

        }

        if (paramsone.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsone.toString());
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/goods", requestId, params);
    }

    /**
     * 查询店铺详情
     */
    public void requestStoresDetails(int requestId) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        params.put("service", "finance.storeDetailFind");
        JSONObject paramsone = new JSONObject();
        try {
            paramsone.put("stores_id", MainActivity.member_id);
        } catch (JSONException e) {

        }

        if (paramsone.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsone.toString());
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/finance", requestId, params);
    }

    /**
     * 话费充值
     *
     * @param mobile          充值手机号
     * @param loginPhone      登录时候手机号
     * @param nickname        昵称(店东端没有昵称 传登录手机号一样)
     * @param goods_id        商品id(话费当成商品)
     * @param payment_way_key 支付方式
     */
    public void requestMobileRechargePay(int requestId, String mobile, String loginPhone, String nickname, String goods_id, String payment_way_key) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        params.put("service", "mobileRecharge.app.orderPay");
        JSONObject paramsone = new JSONObject();
        try {
            paramsone.put("data_source", SettingData.DATA_SOURCE);
            paramsone.put("member_id", MainActivity.member_id);
            paramsone.put("member_mobile", loginPhone);
            paramsone.put("member_name", nickname);
            paramsone.put("member_type_key", "stores");
            paramsone.put("mobile", mobile);
            paramsone.put("goods_id", goods_id);
            paramsone.put("payment_way_key", payment_way_key);
        } catch (JSONException e) {

        }

        if (paramsone.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsone.toString());
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/finance", requestId, params);
    }

    /**
     * 查询加盟店日现金交易统计数据
     *
     * @param transaction_date 日期
     */
    public void requestTradeStatistic(int requestId, String transaction_date) {
        if (TextUtils.isEmpty(MainActivity.user_token) || TextUtils.isEmpty(MainActivity.member_id)) {
            return;
        }
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject paramsone = new JSONObject();
        try {
            paramsone.put("transaction_date", transaction_date);
            paramsone.put("member_id", MainActivity.member_id);
        } catch (JSONException e) {

        }

        if (paramsone.toString().equals("{}")) {
            return;
        }
        params.put("service", "finance.storeCashCount");
        params.put("params", paramsone.toString());
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/finance", requestId, params);
    }

    /**
     * 查询快捷商品接口（展示在收银台）
     */
    public void requestGoodsList(int requestId) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        params.put("service", "storesGoods.stores.cashierGoodsListPageFind");
        JSONObject paramsone = new JSONObject();
        try {
            paramsone.put("stores_id", MainActivity.member_id);
            paramsone.put("is_show", "Y");
        } catch (JSONException e) {
            e.printStackTrace();
        }
        params.put("params", paramsone.toString());
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/goods", requestId, params);
    }

    /**
     * 搜索 其实跟列表是同个接口
     */
    public void requestGoodsSearch(int requestId, String page_no, String page_size, String item_name, String is_discount, String is_sell, String is_show, String product_source) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        params.put("service", "storesGoods.stores.goodsListPageFind");
//        params.put("service", "goods.itemStorePageFindForStores");
        JSONObject pageObj = new JSONObject();
        try {
            pageObj.put("page_no", page_no + "");
            pageObj.put("page_size", page_size);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        params.put("page", pageObj.toString());
        JSONObject paramsone = new JSONObject();
        try {
            paramsone.put("stores_id", MainActivity.member_id);
            if (!TextUtils.isEmpty(item_name)) {
                paramsone.put("item_name", item_name);
            }
            if (is_discount != null) {
                paramsone.put("is_discount", is_discount);
            }
            if (is_sell != null) {
                paramsone.put("is_sell", is_sell);
            }
            if (is_show != null) {
                paramsone.put("is_show", is_show);
            }
            if (product_source != null) {
                paramsone.put("product_source", product_source);
            }
        } catch (JSONException e) {

        }

        if (paramsone.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsone.toString());
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/goods", requestId, params);
    }


    /**
     * 查询银行列表
     */
    public void requestBankList(int requestId, String page_no) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        params.put("service", "finance.bankListPageFind");
        JSONObject pageObj = new JSONObject();
        try {
            pageObj.put("page_no", page_no + "");
            pageObj.put("page_size", "15");
        } catch (JSONException e) {
            e.printStackTrace();
        }
        params.put("page", pageObj.toString());
        params.put("params", new Gson().toJson(params).toString());
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/finance", requestId, params);
    }

    /**
     * 查询我要批类型列表
     */
    public void requestWypType(int requestId) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        params.put("service", "goods.wypGoodsCategoryFind");
        params.put("params", new Gson().toJson("").toString());
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/goods", requestId, params);
    }


    /**
     * 查询分类信息
     */
    public void requestTypeList(int requestId) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        params.put("service", "goods.itemStoreGroupTypeFind");
        params.put("params", "{}");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/goods", requestId, params);
    }

    /**
     * 获取自编码
     */
    public void requestZBM(int requestId) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        params.put("service", "storesGoods.stores.goodsCodeFind");
        params.put("params", "{}");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/goods", requestId, params);
    }

    /**
     * 规格
     */
    public void requestSpecificationUnitFind(int requestId) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        params.put("service", "storesGoods.stores.specificationUnitFind");
        params.put("params", "{}");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/goods", requestId, params);
    }

    /**
     * 查看商品详情
     */
    public void requestGoodsDetails(int requestId, String item_store_id) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        params.put("service", "storesGoods.stores.goodsDetailFind");
        JSONObject paramsone = new JSONObject();
        try {
            paramsone.put("stores_goods_id", item_store_id);
        } catch (JSONException e) {

        }
        if (paramsone.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsone.toString());
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/goods", requestId, params);
    }

    /**
     * 根据商品条码查询商品详情
     */
    public void requestGoodsDetailsByBarcode(int requestId, String barcode) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        params.put("service", "storesGoods.stores.cashierGoodsListPageFind");
        JSONObject paramsone = new JSONObject();
        try {
            paramsone.put("stores_id", MainActivity.member_id);
            paramsone.put("barcode", barcode);
        } catch (JSONException e) {

        }
        if (paramsone.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsone.toString());
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/goods", requestId, params);
    }

    /**
     * 绑定银行卡
     *
     * @param capital_account         账号
     * @param cardholder              持卡人
     * @param organization_code       银行编码
     * @param publishing_institutions 发行机构
     * @param remark                  备注
     * @param front                   第一张图片id
     * @param back                    第二张图片id
     */
    public void requestBindCard(int requestId, String capital_account, String cardholder, String organization_code, String publishing_institutions, String remark, String front, String back) {

        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        params.put("service", "finance.memberCapitalAccountApplicationCreate");

        JSONObject paramsone = new JSONObject();
        try {
            paramsone.put("member_id", MainActivity.member_id);
            paramsone.put("member_type_key", "stores");
            paramsone.put("stores_name", Stores.stores_name);
            paramsone.put("contact_tel", Stores.contact_tel);
            paramsone.put("contact_person", Stores.contact_person);
            paramsone.put("capital_account", capital_account);
            paramsone.put("cardholder", cardholder);
            paramsone.put("organization_code", organization_code);
            paramsone.put("publishing_institutions", publishing_institutions);
            paramsone.put("remark", remark);
            paramsone.put("capital_account_type_key", "ZHFL_03");
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("front", front);
            jsonObject.put("back", back);
            paramsone.put("pic_info", jsonObject.toString());
        } catch (JSONException e) {

        }

        if (paramsone.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsone.toString());
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/finance", requestId, params);
    }


    /**
     * 查询店东收银记录
     */
    public void requestTakeRecords(int requestId, String created_date) {
        if (TextUtils.isEmpty(MainActivity.user_token) || TextUtils.isEmpty(MainActivity.member_id)) {
            return;
        }
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject paramsone = new JSONObject();
        try {
            paramsone.put("created_date", created_date);
            paramsone.put("member_id", MainActivity.member_id);
        } catch (JSONException e) {

        }


        if (paramsone.toString().equals("{}")) {
            return;
        }
        params.put("service", "finance.storesCashierFind");
        params.put("params", paramsone.toString());
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/finance", requestId, params);
    }

    /**
     * 查询用户资产信息
     */
    public void requestQueryAccount(int requestId) {
        if (TextUtils.isEmpty(MainActivity.user_token) || TextUtils.isEmpty(MainActivity.member_id)) {
            return;
        }
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);

        JSONObject paramsone = new JSONObject();
        try {
            paramsone.put("member_id", MainActivity.member_id);
        } catch (JSONException e) {

        }
        if (paramsone.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsone.toString());
        params.put("service", "finance.memberAssetFind");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/finance", requestId, params);
    }

    /**
     * 请求佣金相关的信息：总佣金、待入账佣金、总会员数。
     */
    public void requestCommissionInfo(int requestId) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);

        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("stores_id", MainActivity.member_id);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        params.put("params", jsonObject.toString());
        params.put("service", "order.fgOrderCommissionToAmountMemberTotal");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/opsorder", requestId, params);
    }

    /**
     * 请求所有佣金的日志list.
     */
    public void requestAllCommissionList(int requestId, int pageNo) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);

        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("stores_id", MainActivity.member_id);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        JSONObject pageJsonObject = new JSONObject();
        try {
            pageJsonObject.put("page_no", pageNo + "");
            pageJsonObject.put("page_size", "15");
        } catch (JSONException e) {
            e.printStackTrace();
        }

        params.put("page", pageJsonObject.toString());
        params.put("params", jsonObject.toString());
        params.put("service", "order.fgOrderCommissionListPageFind");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/opsorder", requestId, params);
    }

    /**
     * 请求待入账佣金的日志list。
     */
    public void requestToBeAccountedCommissionList(int requestId, int pageNo) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);

        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("stores_id", MainActivity.member_id);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        JSONObject pageJsonObject = new JSONObject();
        try {
            pageJsonObject.put("page_no", pageNo + "");
            pageJsonObject.put("page_size", "15");
        } catch (JSONException e) {
            e.printStackTrace();
        }

        params.put("page", pageJsonObject.toString());
        params.put("params", jsonObject.toString());
        params.put("service", "order.fgOrderrCommissionWeekAmountPageFind");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/opsorder", requestId, params);
    }

    /**
     * 请求 佣金 页面中的会员个数。
     */
    public void requestCommissionMembersNumber(int requestId) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);

        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("stores_id", MainActivity.member_id);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        params.put("params", jsonObject.toString());
        params.put("service", "member.numberOfMembers");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/member", requestId, params);
    }

    /**
     * 请求 佣金-会员 页面中会员详细信息列表。
     */
    public void requestCommissionMembersList(int requestId, int pageNo) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);

        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("stores_id", MainActivity.member_id);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        JSONObject pageJsonObject = new JSONObject();
        try {
            pageJsonObject.put("page_no", pageNo);
            pageJsonObject.put("page_size", "15");
        } catch (JSONException e) {
            e.printStackTrace();
        }

        params.put("page", pageJsonObject.toString());
        params.put("params", jsonObject.toString());
        params.put("service", "member.memberInformationPage");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/member", requestId, params);
    }

    /**
     * 提现
     *
     * @param amount    提现金额
     */
    public void requestWithdraw(int requestId, String amount) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject paramsone = new JSONObject();
        try {

            paramsone.put("data_source", "SJLY_02");
            paramsone.put("amount", amount);
            paramsone.put("member_id", MainActivity.member_id + "");
            paramsone.put("out_trade_no", IDUtil.getOutTradeNo() + "");
            paramsone.put("detail", "余额提现");
            paramsone.put("out_trade_body", paramsone.toString());
        } catch (JSONException e) {

        }

        if (paramsone.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsone.toString());
        params.put("service", "finance.balanceWithdraw");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/finance", requestId, params);
    }

    /**
     * 查询零钱流水
     */
    public void requestQueryCashLog(int requestId, String page_no) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject paramsone = new JSONObject();
        try {
            paramsone.put("member_type_key", "stores");
            paramsone.put("member_id", MainActivity.member_id);
        } catch (JSONException e) {

        }
        JSONObject pageObj = new JSONObject();
        try {
            pageObj.put("page_no", page_no + "");
            pageObj.put("page_size", "15");
        } catch (JSONException e) {
            e.printStackTrace();
        }

        if (paramsone.toString().equals("{}")) {
            return;
        }
        params.put("page", pageObj.toString());
        params.put("params", paramsone.toString());
        params.put("service", "finance.memberCashLogPageFind");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/finance", requestId, params);
    }

    /**
     * 查询佣金流水
     */
    public void requestQueryCommissionLog(int requestId, String page_no) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject paramsone = new JSONObject();
        try {
            paramsone.put("member_type_key", "stores");
            paramsone.put("member_id", MainActivity.member_id);
        } catch (JSONException e) {

        }
        JSONObject pageObj = new JSONObject();
        try {
            pageObj.put("page_no", page_no + "");
            pageObj.put("page_size", "15");
        } catch (JSONException e) {
            e.printStackTrace();
        }

        if (paramsone.toString().equals("{}")) {
            return;
        }
        params.put("page", pageObj.toString());
        params.put("params", paramsone.toString());
        params.put("service", "finance.stores.storesCashCommissionLogListPageFind");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/finance", requestId, params);
    }

    /**
     * 查询金币流水
     */
    public void requestQueryGoldLog(int requestId, String page_no) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject paramsone = new JSONObject();
        try {
            paramsone.put("member_type_key", "stores");
            paramsone.put("member_id", MainActivity.member_id);
        } catch (JSONException e) {

        }
        JSONObject pageObj = new JSONObject();
        try {
            pageObj.put("page_no", page_no + "");
            pageObj.put("page_size", "15");
        } catch (JSONException e) {
            e.printStackTrace();
        }

        if (paramsone.toString().equals("{}")) {
            return;
        }
        params.put("page", pageObj.toString());
        params.put("params", paramsone.toString());
        params.put("service", "finance.memberGoldLogPageFind");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/finance", requestId, params);
    }

    /**
     * 查询店东绑定的银行账户
     */
    public void requestQueryBankNo(int requestId) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject paramsone = new JSONObject();
        try {
            paramsone.put("member_type_key", "stores");
            paramsone.put("member_id", MainActivity.member_id);
        } catch (JSONException e) {

        }
        if (paramsone.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsone.toString());
        params.put("service", "finance.memberCapitalAccountFind");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/finance", requestId, params);
    }


//    /**
//     * 领了么异常订单数
//     *
//     * @param requestId
//     */
//    public void requestOrderExceptionCount(int requestId) {
//        AjaxParams params = new AjaxParams();
//        params.put("user_token", MainActivity.user_token);
//        JSONObject paramsone = new JSONObject();
//        try {
//            paramsone.put("member_type_key", SettingData.STORES);
//            paramsone.put("member_id", MainActivity.member_id);
//        } catch (JSONException e) {
//
//        }
//        if (paramsone.toString().equals("{}")) {
//            return;
//        }
//        params.put("params", paramsone.toString());
//        params.put("service", "order.fgOrderExceptionCount");
//        params.put("sign", genPackageSignUser(params));
//        requestData("/openapi/opsorder", requestId, params);
//    }

    /**
     * 查询可用余额
     */
    public void requestUsableCashBalanceFind(int requestId) {
        if (TextUtils.isEmpty(MainActivity.user_token) || TextUtils.isEmpty(MainActivity.member_id)) {
            return;
        }
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);

        JSONObject paramsone = new JSONObject();
        try {
            paramsone.put("member_id", MainActivity.member_id);
            paramsone.put("member_type_key", "stores");
        } catch (JSONException e) {

        }
        params.put("params", paramsone.toString());
        params.put("service", "finance.usableCashBalanceFind");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/finance", requestId, params);
    }

    /**
     * 查询会员注册数详细信息
     */
    public void requestRegistMemeberList(int requestId, String reference_id) {
        AjaxParams params = new AjaxParams();
        params.put("app_token", MainActivity.app_token);
        params.put("service", "member.storesRelConsumerAssetList");
        JSONObject pageObj = new JSONObject();
//        try {
//            pageObj.put("page_no", page_no + "");
//            pageObj.put("page_size", page_size);
//        } catch (JSONException e) {
//            e.printStackTrace();
//        }
//        params.put("page", pageObj.toString());
        JSONObject paramsone = new JSONObject();
        try {
            paramsone.put("stores_id", reference_id);
        } catch (JSONException e) {

        }
        if (paramsone.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsone.toString());
        params.put("sign", genPackageSign(params));
        requestData("/openapi/member", requestId, params);
    }

    /**
     * 根据交易流水号查询交易状态，成功之后才去调收银记录
     */
    public void requestTransactionStatusFind(int requestId, String transaction_no) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject paramsone = new JSONObject();
        try {
            paramsone.put("transaction_no", transaction_no);
        } catch (Exception e) {
        }
        if (paramsone.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsone.toString());
        params.put("service", "trade.transactionStatusFind");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/finance", requestId, params);
    }

    /**
     * 通知服务器促销
     *
     * @param card_no         亲情卡号 有就传
     * @param detail          交易详情
     * @param payment_way_key 支付方式
     * @param amount          原始金额
     * @param reduce_amount   满减金额
     * @param discount_amount 抵扣金额
     * @param rebate_cash     返现
     * @param reward_gold     送金币
     * @param pay_amount      实收金额
     * @param transaction_no  支付成功后返回的交易号
     * @param card_no         // 扫码流水号（仅限扫码支付）
     * @param security_code   // 扫码支付时候传 security_code
     */
    public void requestStoreCashierPromotion(int requestId, String out_trade_no, String buyer_id, String seller_id, String detail, String payment_way_key, String amount, String reduce_amount, String discount_amount, String rebate_cash, String reward_gold, String pay_amount, String transaction_no, String security_code, String card_no) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject paramsone = new JSONObject();
        try {
            paramsone.put("data_source", "SJLY_02");
            paramsone.put("detail", detail);
            paramsone.put("out_trade_no", out_trade_no);
            paramsone.put("payment_way_key", payment_way_key);
            paramsone.put("buyer_id", buyer_id);
            paramsone.put("seller_id", seller_id);
            paramsone.put("amount", amount);
            paramsone.put("reduce_amount", reduce_amount);
            paramsone.put("discount_amount", discount_amount);
            paramsone.put("rebate_cash", rebate_cash);
            paramsone.put("reward_gold", reward_gold);
            paramsone.put("pay_amount", pay_amount);
            paramsone.put("transaction_no", transaction_no);
            paramsone.put("flow_no", out_trade_no);
            if (!TextUtils.isEmpty(card_no)) {
                paramsone.put("card_no", card_no);
            }
//            if (!TextUtils.isEmpty(security_code)) {
//                paramsone.put("security_code", security_code);
//            }
        } catch (Exception e) {
        }
        if (paramsone.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsone.toString());
        params.put("service", "finance.storeCashierPromotion");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/finance", requestId, params);
    }

    /**
     * 查询店铺详情
     */
    public void requestQueryStoresInfo(int requestId) {
        AjaxParams params = new AjaxParams();
        try {
            params.put("user_token", MainActivity.user_token);
            JSONObject paramsone = new JSONObject();
            paramsone.put("stores_id", MainActivity.member_id);
            params.put("params", paramsone.toString());
            params.put("service", "member.storeDetailFind");
            params.put("sign", genPackageSignUser(params));
            requestData("/openapi/member", requestId, params);
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    /**
     * 扫描亲情卡，查询会员信息
     */
    public void requestCardScan(int requestId, String card_no) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject paramsone = new JSONObject();
        try {
            paramsone.put("card_no", card_no);
        } catch (Exception e) {
        }

        if (paramsone.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsone.toString());
        params.put("service", "finance.storesPrepayCardScan");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/finance", requestId, params);
    }

    /**
     * 注册交易
     */
    public void requestReg(int requestId) {
        AjaxParams params = new AjaxParams();
        params.put("app_token", MainActivity.app_token);
        params.put("sign", genPackageSign(params));
        requestData("/openapi/trade/reg", requestId, params);
    }

    public String time_String(long first_time) {
        Date date = new Date(first_time * 1000);
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        String dateString = formatter.format(date);
        return dateString;
    }

    /**
     * 亲情卡支付
     */
    public void requestCardPay(int requestId, String seller_id, String card_no, String money) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject paramsone = new JSONObject();
        try {
            paramsone.put("data_source", "SJLY_02");
            Long tsLong = System.currentTimeMillis() / 1000;
            paramsone.put("transaction_date", time_String(tsLong));
            paramsone.put("detail", "亲情卡");
            paramsone.put("amount", money + "");
            paramsone.put("out_trade_no", IDUtil.getOutTradeNo());
            paramsone.put("payment_way_key", SettingData.PAYMENT_WAY_05);
            paramsone.put("seller_id", seller_id);
            paramsone.put("card_no", card_no);
            paramsone.put("out_trade_body", paramsone.toString());
        } catch (Exception e) {
        }

        if (paramsone.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsone.toString());
        params.put("service", "finance.prepayCardPay");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/finance", requestId, params);
    }

    /**
     * 亲情卡查询
     */
    public void requestCheckFamilyCard(int requestId, String card_no) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject paramsone = new JSONObject();
        try {
            paramsone.put("card_no", card_no);
        } catch (Exception e) {
        }

        if (paramsone.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsone.toString());
        params.put("service", "finance.storesPrepayCardScan");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/finance", requestId, params);
    }

    /**
     * 验证付款码交易
     */
    public void requestTradeVerify(int requestId, String flow_no, String security_code) {
        AjaxParams params = new AjaxParams();
        params.put("app_token", MainActivity.app_token);
        params.put("flow_no", flow_no);
        params.put("security_code", security_code);
        params.put("sign", genPackageSign(params));
        requestData("/openapi/trade/verify", requestId, params);
//
//
//        AjaxParams params = new AjaxParams();
//
//        params.put("app_token", MainActivity.app_token);
//        params.put("flow_no", flow_no);
//        params.put("security_code", security_code);
//        params.put("params", params.toString());
//        params.put("sign", genPackageSign(params));
//        requestData("/openapi/trade/verify", requestId, params);
    }

    /**
     * 登录环信（如果不存在后台回自动注册创建）
     *
     * @param nick_name       昵称
     * @param head_pic_path   头像
     */
    public void requestHXIMUserLogin(int requestId, String member_id, String member_type_key, String nick_name, String head_pic_path) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("member_id", member_id);
            jsonObject.put("member_type_key", member_type_key);
            if (!TextUtils.isEmpty(nick_name)) {
                jsonObject.put("nickname", nick_name);
            }
            if (!TextUtils.isEmpty(head_pic_path)) {
                jsonObject.put("head_pic_path", head_pic_path);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        if (jsonObject.toString().equals("{}")) {
            return;
        }
        params.put("params", jsonObject.toString());
        params.put("service", "chat.getIMUserLoginInfo");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/community", requestId, params);
    }

    /**
     * 根据memeberid等信息查询环信的用户id
     */
    public void requestHXIMLeidaAccount(int requestId, String group_id) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("group_id", group_id);
        } catch (Exception e) {
        }

        if (jsonObject.toString().equals("{}")) {
            return;
        }
        params.put("params", jsonObject.toString());
        params.put("service", "chat.getChatGroupLocationUsers");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/community", requestId, params);
    }

    /**
     * 群添加成员列表
     */
    public void requestHXCreateChatGroupWithMembers(int requestId, String group_name, String desc, String created_by, String member_info) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("group_name", group_name);
            jsonObject.put("desc", desc);
            jsonObject.put("created_by", created_by);
            jsonObject.put("member_info", member_info);
        } catch (Exception e) {
            e.printStackTrace();
        }

        if (jsonObject.toString().equals("{}")) {
            return;
        }
        params.put("params", jsonObject.toString());
        params.put("service", "chat.createChatGroupWithMembers");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/community", requestId, params);
    }

    /**
     * 群移除成员列表
     */
    public void requestHXremoveBatchUsersFromChatGroup(int requestId, String group_id, String im_user_ids) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("group_id", group_id);
            jsonObject.put("im_user_ids", im_user_ids);
        } catch (Exception e) {
            e.printStackTrace();
        }

        if (jsonObject.toString().equals("{}")) {
            return;
        }
        params.put("params", jsonObject.toString());
        params.put("service", "chat.removeBatchUsersFromChatGroup");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/community", requestId, params);
    }

    /**
     * 群添加成员列表
     */
    public void requestHXaddBatchUsersToChatGroup(int requestId, String group_id, String member_info) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("group_id", group_id);
            jsonObject.put("member_info", member_info);
        } catch (Exception e) {
            e.printStackTrace();
        }

        if (jsonObject.toString().equals("{}")) {
            return;
        }
        params.put("params", jsonObject.toString());
        params.put("service", "chat.addBatchUsersToChatGroup");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/community", requestId, params);
    }

    /**
     * 根据memeberid等信息查询环信的用户id
     */
    public void requestHXIMUserAccount(int requestId, String member_id, String member_type_key) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("member_id", member_id);
            jsonObject.put("member_type_key", member_type_key);
        } catch (Exception e) {
        }

        if (jsonObject.toString().equals("{}")) {
            return;
        }
        params.put("params", jsonObject.toString());
        params.put("service", "chat.getIMUserAccount");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/community", requestId, params);
    }

    /**
     * 修改用户个人资料
     *
     * @param username      用户名
     * @param nickname      昵称
     * @param head_pic_path 头像
     * @param sex_key       性别
     * @param birthday      生日
     */
    public void requestHXModifyIMUserInfo(int requestId, String im_user_id, String username, String nickname, String head_pic_path, String sex_key, String birthday) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("im_user_id", im_user_id);
            if (!TextUtils.isEmpty(username)) {
                jsonObject.put("username", username);
            }
            if (!TextUtils.isEmpty(nickname)) {
                jsonObject.put("nickname", nickname);
            }
            if (!TextUtils.isEmpty(head_pic_path)) {
                jsonObject.put("head_pic_path", head_pic_path);
            }
            if (!TextUtils.isEmpty(sex_key)) {
                jsonObject.put("sex_key", sex_key);
            }
            if (!TextUtils.isEmpty(birthday)) {
                jsonObject.put("birthday", birthday);
            }
        } catch (Exception e) {
        }
        params.put("params", jsonObject.toString());
        params.put("service", "chat.modifyIMUserInfo");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/community", requestId, params);
    }

    /**
     * 创建直播室
     *
     * @param name       直播室名称
     * @param cover      封面图片
     * @param url        直播地址
     * @param desc       描述
     * @param label      标签（体育类型等）
     * @param created_by 创建者
     */
    public void requestHXOpenOneLiveRoom(int requestId, String name, String cover, String url, String desc, String label, String created_by) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject jsonObject = new JSONObject();
        try {
            if (!TextUtils.isEmpty(name)) {
                jsonObject.put("name", name);
            }
            if (!TextUtils.isEmpty(cover)) {
                jsonObject.put("cover", cover);
            }
            if (!TextUtils.isEmpty(url)) {
                jsonObject.put("url", url);
            }
            if (!TextUtils.isEmpty(desc)) {
                jsonObject.put("desc", desc);
            }
            if (!TextUtils.isEmpty(label)) {
                jsonObject.put("label", label);
            }
            if (!TextUtils.isEmpty(created_by)) {
                jsonObject.put("created_by", created_by);
            }
        } catch (Exception e) {
        }
        params.put("params", jsonObject.toString());
        params.put("service", "live.openOneLiveRoom");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/community", requestId, params);
    }

    /**
     * 关闭直播室
     *
     * @param im_user_id 群主id
     */
    public void requestHXCloseOneLiveRoom(int requestId, String im_user_id, String room_id) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject jsonObject = new JSONObject();
        try {
            if (!TextUtils.isEmpty(im_user_id)) {
                jsonObject.put("im_user_id", im_user_id);
            }
            if (!TextUtils.isEmpty(room_id)) {
                jsonObject.put("room_id", room_id);
            }

        } catch (Exception e) {
        }

        if (jsonObject.toString().equals("{}")) {
            return;
        }
        params.put("params", jsonObject.toString());
        params.put("service", "live.closeOneLiveRoom");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/community", requestId, params);
    }

    /**
     * 查询用户开播中的直播室
     */
    public void requestHXQueryUserLiveRoom(int requestId, String im_user_id) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject jsonObject = new JSONObject();
        try {
            if (!TextUtils.isEmpty(im_user_id)) {
                jsonObject.put("im_user_id", im_user_id);
            }
        } catch (Exception e) {
        }

        if (jsonObject.toString().equals("{}")) {
            return;
        }
        params.put("params", jsonObject.toString());
        params.put("service", "live.queryUserLiveRoom");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/community", requestId, params);
    }

    /**
     * 根据im_user_id查询用户资料
     */
    public void requestHXIMUserDetail(int requestId, String im_user_id) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("im_user_id", im_user_id);
        } catch (Exception e) {
        }

        if (jsonObject.toString().equals("{}")) {
            return;
        }
        params.put("params", jsonObject.toString());
        params.put("service", "chat.getIMUserDetail");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/community", requestId, params);
    }

    /**
     * 获取直播室详情
     */
    public void requestHXGetLiveRoomDetails(int requestId, String room_id) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("room_id", room_id);
        } catch (Exception e) {
        }

        if (jsonObject.toString().equals("{}")) {
            return;
        }
        params.put("params", jsonObject.toString());
        params.put("service", "live.getLiveRoomDetails");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/community", requestId, params);
    }

    /**
     * 添加用户到直播室
     */
    public void requestHXAddUserToLiveRoom(int requestId, String im_user_id, String room_id) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("room_id", room_id);
            jsonObject.put("im_user_id", im_user_id);
        } catch (Exception e) {
        }

        if (jsonObject.toString().equals("{}")) {
            return;
        }
        params.put("params", jsonObject.toString());
        params.put("service", "live.addUserToLiveRoom");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/community", requestId, params);
    }

    /**
     * 用户退出直播室
     */
    public void requestHXRemoveUserFromLiveRoom(int requestId, String im_user_id, String room_id) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("room_id", room_id);
            jsonObject.put("im_user_id", im_user_id);
        } catch (Exception e) {
        }

        if (jsonObject.toString().equals("{}")) {
            return;
        }
        params.put("params", jsonObject.toString());
        params.put("service", "live.removeUserFromLiveRoom");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/community", requestId, params);
    }

    /**
     * 查询直播室成员
     */
    public void requestHXGetLiveRoomUsers(int requestId, String room_id) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("room_id", room_id);
        } catch (Exception e) {
        }

        if (jsonObject.toString().equals("{}")) {
            return;
        }
        params.put("params", jsonObject.toString());
        params.put("service", "live.getLiveRoomUsers");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/community", requestId, params);
    }

    /**
     * 创建群组
     *
     * @param group_name 群组名称
     * @param desc       群组描述
     * @param created_by 创建时间
     */
    public void requestHXCreateGroup(int requestId, String group_name, String desc, String created_by) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("group_name", group_name);
            jsonObject.put("desc", desc);
            jsonObject.put("created_by", created_by);
        } catch (Exception e) {
        }

        if (jsonObject.toString().equals("{}")) {
            return;
        }
        params.put("params", jsonObject.toString());
        params.put("service", "chat.createGroup");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/community", requestId, params);
    }


    /**
     * 解散群
     */
    public void requestHXDissolveGroup(int requestId, String group_id, String im_user_id) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("group_id", group_id);
            jsonObject.put("im_user_id", im_user_id);

        } catch (Exception e) {
        }
        if (jsonObject.toString().equals("{}")) {
            return;
        }
        params.put("params", jsonObject.toString());
        params.put("service", "chat.deleteChatGroup");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/community", requestId, params);

    }


    /**
     * 查询用户群组列表
     *
     * @param im_user_id 用户id
     */
    public void requestHXGroupList(int requestId, String im_user_id) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("im_user_id", im_user_id);
        } catch (Exception e) {
        }
        if (jsonObject.toString().equals("{}")) {
            return;
        }
        params.put("params", jsonObject.toString());
        params.put("service", "chat.getIMUserGroupList");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/community", requestId, params);
    }

    /**
     * 添加单个用户到群组
     */
    public void requestHXAddSingleUserToChatGroup(int requestId, String im_user_id, String group_id) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("im_user_id", im_user_id);
            jsonObject.put("group_id", group_id);
        } catch (Exception e) {
        }

        if (jsonObject.toString().equals("{}")) {
            return;
        }
        params.put("params", jsonObject.toString());
        params.put("service", "chat.addSingleUserToChatGroup");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/community", requestId, params);
    }

    /**
     * 获取群成员列表
     */
    public void requestHXGroupMenberList(int requestId, String group_id) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("group_id", group_id);
        } catch (Exception e) {
        }

        if (jsonObject.toString().equals("{}")) {
            return;
        }
        params.put("params", jsonObject.toString());
        params.put("service", "chat.getChatGroupUsers");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/community", requestId, params);
    }


    /**
     * 获取要加到群的群成员列表
     */
    public void requestHXgetAddibleUsersForChatGroup(int requestId, String group_id) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("group_id", group_id);
            jsonObject.put("stores_id", MainActivity.member_id);

        } catch (Exception e) {
        }

        if (jsonObject.toString().equals("{}")) {
            return;
        }
        params.put("params", jsonObject.toString());
        params.put("service", "chat.getAddibleUsersForChatGroup");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/community", requestId, params);
    }

    /**
     * 通过群id查询群资料
     */
    public void requestHXGroupDetails(int requestId, String group_id) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("group_id", group_id);
        } catch (Exception e) {
        }

        if (jsonObject.toString().equals("{}")) {
            return;
        }
        params.put("params", jsonObject.toString());
        params.put("service", "chat.getChatGroupDetails");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/community", requestId, params);
    }

    /**
     * 获取的apptoken跟SecurityCode
     */
    public void requestGetAppTokenAndSecurityCode(int requestId) {
        AjaxParams params = new AjaxParams();
        params.put("app_id", SettingData.app_id);
        params.put("private_key", SettingData.private_key);
        requestData("/openapi/app/login", requestId, params);
    }


    /**
     * 余额充值生成预订单
     */
    public void requestBalanceRecharge(int requestId, String payment_way_key, String money) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject paramsObj = new JSONObject();
        try {
            paramsObj.put("data_source", "SJLY_02");
            paramsObj.put("payment_way_key", payment_way_key);
            paramsObj.put("detail", "余额充值");
            paramsObj.put("amount", money);
            paramsObj.put("member_id", MainActivity.member_id);
            paramsObj.put("out_trade_no", IDUtil.getOutTradeNo());
            paramsObj.put("out_trade_bady", paramsObj.toString());
        } catch (JSONException e) {
            e.printStackTrace();
        }

        if (paramsObj.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsObj.toString());
        params.put("service", "finance.balanceRecharge");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/finance", requestId, params);
    }

    /**
     * 激活亲情卡
     *
     * @param cardNo    亲情卡号
     */
    public void requestCardActivate(int requestId, String cardNo) {
        if (TextUtils.isEmpty(cardNo)) {
            return;
        }
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject paramsObj = new JSONObject();
        try {
            paramsObj.put("member_id", MainActivity.member_id);
            paramsObj.put("card_no", cardNo);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        if (paramsObj.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsObj.toString());
        params.put("service", "finance.prepayCardActivate");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/finance", requestId, params);
    }

    /**
     * 查询亲情卡状态
     *
     * @param cardNo    亲情卡号
     */
    public void requestQueryCardState(int requestId, String cardNo) {
        if (TextUtils.isEmpty(cardNo)) {
            return;
        }
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject paramsObj = new JSONObject();
        try {
            paramsObj.put("member_id", MainActivity.member_id);
            paramsObj.put("card_no", cardNo);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        if (paramsObj.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsObj.toString());
        params.put("service", "finance.prepayCardStatusFind");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/finance", requestId, params);
    }

    /**
     * 亲情卡绑定会员
     */
    public void requestCardBind(int requestId, String card_no, String member_id, String mobile) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject paramsObj = new JSONObject();
        try {
            paramsObj.put("member_id", member_id);
            paramsObj.put("card_no", card_no);
            paramsObj.put("remark", card_no);


            paramsObj.put("mobile", mobile);   //添加手机号
        } catch (JSONException e) {
            e.printStackTrace();
        }

        if (paramsObj.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsObj.toString());
        params.put("service", "finance.consumerPrepayCardBind");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/finance", requestId, params);
    }

//    /**
//     * 查询会员基本信息
//     * @param requestId
//     * @param mobile
//     */
//    public void requestQueryMemberInfo(int requestId,String mobile){
//        AjaxParams params = new AjaxParams();
//        params.put("app_token", MainActivity.app_token);
//        JSONObject paramsObj = new JSONObject();
//        try {
//            paramsObj.put("mobile", mobile);
//            paramsObj.put("member_type_key", "consumer");
//        } catch (JSONException e) {
//            e.printStackTrace();
//        }
//        params.put("params", paramsObj.toString());
//        params.put("service", "member.memberInfoFindByMobile");
//    }

    /**
     * 验证短信
     *
     * @param sms_code  验证码
     */
    public void requestValidSMS(int requestId, String mobile, String sms_code) {
        AjaxParams params = new AjaxParams();
        params.put("app_token", MainActivity.app_token);
        params.put("mobile", mobile);
        params.put("sms_code", sms_code);
        params.put("sign", genPackageSign(params));
        requestData("/openapi/notify/valid_sms_code", requestId, params);
    }

    /**
     * 验证user_token是否有效
     */
    public void requestVerifyUserToken(int requestId) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/user/verify_user_token", requestId, params);
    }

    /**
     * 验证会员类型
     *
     * @param account   手机号
     */
    public void requestAuthType(int requestId, String account) {
        AjaxParams params = new AjaxParams();
        params.put("app_token", MainActivity.app_token);
        params.put("member_type_key", "stores");
        params.put("mobile", account);
        params.put("sign", genPackageSign(params));
        requestData("/openapi/user/valid_type_by_mobile", requestId, params);
    }

    public void requestAppToken(int requestId) {
        AjaxParams params = new AjaxParams();
        params.put("app_id", SettingData.app_id);
        params.put("private_key", SettingData.private_key);
        requestData("/openapi/app/login", requestId, params);
    }


    /**
     * 根据图片id获取图片url
     */
    public void requestGetPicUrl(int requestId, String doc_id) {
        AjaxParams params = new AjaxParams();
        params.put("app_token", MainActivity.app_token);
        params.put("doc_ids", doc_id);
        requestData("/ops-storage/storage/preview", requestId, params);
    }

    /**
     * 保存促销规则
     */
    public void requestStoreActivityPaymentEdit(int requestId, JSONObject rewardObj, JSONObject rebateObj, JSONObject discount) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        params.put("service", "member.storeActivityPaymentEdit");
        JSONArray jsonArray = new JSONArray();
        try {
            jsonArray.put(rewardObj);
            jsonArray.put(rebateObj);
            jsonArray.put(discount);
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("store_activity", jsonArray.toString());
            params.put("params", jsonObject.toString());
        } catch (Exception e) {
        }
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/member", requestId, params);
    }

    /**
     * 更新海报五张图片的信息
     */
    public void requestStoreUpdatePosters(int requestId, JSONArray jsonArray) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        params.put("service", "member.storeEdit");
        try {
            JSONObject jsonObject = new JSONObject();
            jsonObject.put("activity_pic_info", jsonArray.toString());
            jsonObject.put("member_id", MainActivity.member_id);
            params.put("params", jsonObject.toString());
        } catch (Exception e) {
        }
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/member", requestId, params);
    }

    /**
     * 促销规则查询
     */
    public void requestStoreActivityPaymentFind(int requestId) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        params.put("service", "member.storeActivityPaymentFind");
        JSONObject paramsone = new JSONObject();
        try {
            paramsone.put("stores_id", MainActivity.member_id);
        } catch (JSONException e) {

        }

        if (paramsone.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsone.toString());
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/member", requestId, params);
    }

    /**
     * @param account      手机号
     * @param smsCode      验证码
     * @param request_info 设备id
     */
    public void requestLogin(int requestId, String app_token, String account, String smsCode, String request_info) {
        AjaxParams params = new AjaxParams();
        params.put("app_token", app_token);
        params.put("data_source", "store_assistant");
        params.put("device_model", TestDeviveInfo.getDeviceInfo() + "");
        params.put("mobile", account);
        params.put("sms_code", smsCode);
        params.put("request_info", request_info);
        params.put("sign", genPackageSign(params));
        requestData("/openapi/store/login", requestId, params);
    }

    /**
     * 发送验证码之前获取验证信息
     */
    public void requestSendSmsCodeMess(int requestId, String app_token) {
        AjaxParams params = new AjaxParams();
        params.put("app_token", app_token);
        params.put("service", "infrastructure.securityVerify");
        params.put("sign", genPackageSign(params));
        requestData("/openapi/infrastructure", requestId, params);
    }

    /**
     * 发送验证码
     *
     * @param mobile 手机号
     */
    public void requestSendSmsCode(int requestId, String app_token, String mobile,String lock_value) {
        AjaxParams params = new AjaxParams();
        params.put("app_token", app_token);
        params.put("mobile", mobile);
        params.put("lock_value", lock_value);
        params.put("sign", genPackageSign(params));
        requestData("/openapi/notify/send_sms_code", requestId, params);
    }


    /**
     * 查询会员冻结信息
     */
    public void requestUnfreeze_info(int requestId, String member_id) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        params.put("member_id", member_id);
        params.put("member_type_key", "consumer");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/statistic/member/unfreeze_info", requestId, params);
    }


    /**
     * 会员注册数详情
     *
     * @param reference_type_key 店东助手固定传 stores
     * @param reference_id       店东id
     */
    public void requestRegistDetail(int requestId, String page_no, String page_size, String reference_type_key, String reference_id) {
        AjaxParams params = new AjaxParams();
        params.put("app_token", MainActivity.app_token);
        params.put("service", "member.memberRegisterRecommendPageFind");
        JSONObject pageObj = new JSONObject();
        try {
            pageObj.put("page_no", page_no + "");
            pageObj.put("page_size", page_size);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        params.put("page", pageObj.toString());
        JSONObject paramsone = new JSONObject();
        try {
            paramsone.put("reference_type_key", reference_type_key);
            paramsone.put("reference_id", reference_id);
        } catch (JSONException e) {

        }

        if (paramsone.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsone.toString());

        params.put("sign", genPackageSign(params));
        requestData("/openapi/member", requestId, params);
    }

    /**
     * 注册交易关系（方便后台知道谁与谁交易）
     */
    public void requestStoresMemberRelCreate(int requestId, String consumer_id) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        params.put("service", "stores.app.storesMemberRelCreate");
        JSONObject paramsone = new JSONObject();
        try {
            paramsone.put("consumer_id", consumer_id);
            paramsone.put("stores_id", MainActivity.member_id);
        } catch (JSONException e) {

        }

        if (paramsone.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsone.toString());
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/member", requestId, params);
    }

    /**
     * 礼券赠送详情
     */
    public void requestSendCouponDetail(int requestId, String page_no, String page_size, String member_id) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        params.put("service", "finance.storeVoucherBillPage");
        JSONObject pageObj = new JSONObject();
        try {
            pageObj.put("page_no", page_no + "");
            pageObj.put("page_size", page_size);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        params.put("page", pageObj.toString());
        JSONObject paramsone = new JSONObject();
        try {
            paramsone.put("business_type_key", "JYLX_09");
            paramsone.put("member_id", member_id);
            paramsone.put("transaction_date_start", DateUtil.getFormatDate(DateUtil.fmt_yyyyMM) + "-01");
            paramsone.put(" transaction_date_end", DateUtil.getFormatDate(DateUtil.fmt_yyyyMMdd));
        } catch (JSONException e) {

        }

        if (paramsone.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsone.toString());
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/finance", requestId, params);
    }

    public void requestStoresUnfreezeBalanceForConsumer(int requestId, String consumer_id) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        params.put("service", "finance.storesUnfreezeBalanceForConsumer");
        JSONObject paramsone = new JSONObject();
        try {
            paramsone.put("data_source", "SJLY_02");
            paramsone.put("stores_id", MainActivity.member_id);
            paramsone.put("stores_name", Stores.stores_name);
            paramsone.put("consumer_id", consumer_id);
        } catch (JSONException e) {

        }

        if (paramsone.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsone.toString());
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/finance", requestId, params);
    }

    /**
     * 会员开卡详情
     */
    public void requestOpenCard(int requestId, String page_no, String page_size, String stores_id) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        params.put("service", "finance.prepayCardActivatePageFind");
        JSONObject pageObj = new JSONObject();
        try {
            pageObj.put("page_no", page_no + "");
            pageObj.put("page_size", page_size);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        params.put("page", pageObj.toString());
        JSONObject paramsone = new JSONObject();
        try {
            paramsone.put("stores_id", stores_id);
            paramsone.put("created_date_start", Utils.getMonthStartData());
            paramsone.put("created_date_end", Utils.getMonthEndData());
        } catch (JSONException e) {

        }

        if (paramsone.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsone.toString());
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/finance", requestId, params);
    }


    /**
     * 会员交易记录
     */
    public void requestTradeRecord(int requestId, String page_no, String page_size, String stores_id) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        params.put("service", "finance.tradeConsumerListForStores");
        JSONObject pageObj = new JSONObject();
        try {
            pageObj.put("page_no", page_no + "");
            pageObj.put("page_size", page_size);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        params.put("page", pageObj.toString());
        JSONObject paramsone = new JSONObject();
        try {
            paramsone.put("stores_id", stores_id);
        } catch (JSONException e) {

        }

        if (paramsone.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsone.toString());
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/finance", requestId, params);
    }

    public void requestAddCoupon(int requestId, String category_id, String title, String desc1, String pic_path,
                                 String cost_price,
                                 String market_price_voucher, String market_price_gold, String market_price_bonus, String coupon_prop,
                                 String voucher_amount, String settle_price, String limit_amount, String issued_num
            , String expired_date, String per_limit) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        params.put("service", "goods.couponIssueApply");

        JSONObject paramsone = new JSONObject();
        try {
            paramsone.put("category_id", category_id);
            paramsone.put("title", title);
            paramsone.put("desc1", desc1);
            paramsone.put("pic_path", pic_path);
            paramsone.put("member_type_key", "stores");
            paramsone.put("member_id", MainActivity.member_id);
            paramsone.put("cost_price", cost_price);//这三个值暂时一样
            paramsone.put("market_price", cost_price);
            paramsone.put("vip_price", cost_price);
            paramsone.put("market_price_voucher", market_price_voucher);
            paramsone.put("market_price_gold", market_price_gold);
            paramsone.put("market_price_bonus", market_price_bonus);
            paramsone.put("coupon_prop", coupon_prop);
            paramsone.put("voucher_amount", voucher_amount);
            paramsone.put("settle_price", settle_price);
            paramsone.put("limit_amount", limit_amount);
            paramsone.put("issued_num", issued_num);
            paramsone.put("per_limit", per_limit);
//            paramsone.put("used_num", used_num);      此字段不需要上传，但查询数据时候会返回
//            paramsone.put("verified_num", verified_num);
            paramsone.put("expired_date", expired_date);
            paramsone.put("is_refund_anytime", "N");
            paramsone.put("is_refund_expired", "N");

            if (paramsone.toString().equals("{}")) {
                return;
            }
            params.put("params", paramsone.toString());
            params.put("sign", genPackageSignUser(params));
        } catch (JSONException e) {

        }
        requestData("/openapi/goods", requestId, params);
    }

    /**
     * 查询所有优惠券
     */
    public void requestCouponFind(int requestId) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        params.put("service", "goods.couponListFindForStores");
        JSONObject paramsone = new JSONObject();
        try {
            paramsone.put("stores_id", MainActivity.member_id);
        } catch (JSONException e) {

        }

        if (paramsone.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsone.toString());
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/goods", requestId, params);
    }

    /**
     * 查询优惠券详情
     */
    public void requestCouponFindDetail(int requestId, String item_id) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        params.put("service", "goods.couponDetailForStoresFind");
        JSONObject paramsone = new JSONObject();
        try {
            paramsone.put("item_id", item_id);
        } catch (JSONException e) {

        }

        if (paramsone.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsone.toString());
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/goods", requestId, params);
    }

    /**
     * 提交店铺资料
     */
    public void requestSubmitStoresInfo(int requestId, String address, String doc_id, String head_iv, JSONArray stores_thumbnail_path, String store_desc, String s_longitude, String s_latitude, String activity_servcie) {
        AjaxParams params = new AjaxParams();
        params.put("app_token", MainActivity.app_token);
        JSONObject paramsone = new JSONObject();
        try {
            paramsone.put("address", address);
            paramsone.put("desc1", store_desc);
            paramsone.put("member_id", MainActivity.member_id);
            if (!TextUtils.isEmpty(s_longitude) && !s_longitude.contains("E")) {
                paramsone.put("longitude", s_longitude);
                Stores.longitude = s_longitude;
            }
            if (!TextUtils.isEmpty(s_latitude) && !s_latitude.contains("E")) {
                paramsone.put("latitude", s_latitude);
                Stores.latitude = s_latitude;
            }
            if (!TextUtils.isEmpty(doc_id)) {
                paramsone.put("neighbor_pic_path", doc_id);
            }
            if (!TextUtils.isEmpty(head_iv)) {
                paramsone.put("head_pic_path", head_iv);
            }
            if (!TextUtils.isEmpty(activity_servcie)) {
                paramsone.put("activity_servcie", activity_servcie);
            }
            paramsone.put("stores_thumbnail_path", stores_thumbnail_path.toString());
        } catch (JSONException e) {

        }

        if (paramsone.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsone.toString());
        params.put("service", "member.storeEdit");
        params.put("sign", genPackageSign(params));
        requestData("/openapi/member", requestId, params);
    }

    public void requestSetStoresInfo(int requestId, String opening_time, String deliveried_scope, String over_amount) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject paramsone = new JSONObject();
        try {
            paramsone.put("member_id", MainActivity.member_id);
            if (!TextUtils.isEmpty(opening_time)) {
                paramsone.put("opening_time", opening_time);
            }
            if (!TextUtils.isEmpty(deliveried_scope)) {
                paramsone.put("deliveried_range", deliveried_scope);
            } else {
                paramsone.put("deliveried_range", "0");
            }
            if (!TextUtils.isEmpty(over_amount)) {
                paramsone.put("over_amount", over_amount);
            } else {
                paramsone.put("over_amount", "0.00");
            }
        } catch (JSONException e) {

        }
        if (paramsone.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsone.toString());
        params.put("service", "member.storeEdit");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/member", requestId, params);
    }

    /**
     * 优惠券下架
     */
    public void requestCouponDown(int requestId, String item_id, String remark) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        params.put("service", "goods.sysitemItemOffShelf");
        JSONObject paramsone = new JSONObject();
        try {
            paramsone.put("item_id", item_id);
            paramsone.put("remark", remark);
        } catch (JSONException e) {
        }

        if (paramsone.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsone.toString());
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/goods", requestId, params);
    }

    /**
     * 门店营业信息查询(掌上超市信息)
     */
    public void requestBusinessInfoFind(int requestId) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        params.put("service", "stores.stores.storesBusinessInfoFind");
        JSONObject paramsone = new JSONObject();
        try {
            paramsone.put("stores_id", MainActivity.member_id);
        } catch (JSONException e) {
        }

        if (paramsone.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsone.toString());
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/member", requestId, params);
    }

    /**
     * 优惠券数量查询
     */
    public void requestCouponCount(int requestId) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        params.put("service", "goods.storesCouponTotal");
        JSONObject paramsone = new JSONObject();
        try {
            paramsone.put("member_id", MainActivity.member_id);
        } catch (JSONException e) {

        }

        if (paramsone.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsone.toString());
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/goods", requestId, params);
    }

    public void requestAddOneYuanBuy(int requestId, String title, String end_date,
                                     String award_name,
                                     String award_value, String person_num, String award_pic_path1) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        params.put("service", "goods.ldActivitiesCreate");

        JSONObject paramsone = new JSONObject();
        try {
            paramsone.put("stores_id", MainActivity.member_id);//门店id
            paramsone.put("title", title);//标题
            paramsone.put("desc1", "");//描述
            paramsone.put("end_date", end_date);//截止时间
            paramsone.put("award_name", award_name);//奖品名称
            paramsone.put("award_value", award_value);//奖品价值
            paramsone.put("person_num", person_num);//参与人数限制
            paramsone.put("award_pic_path1", award_pic_path1);
            paramsone.put("award_pic_path2", "");
            paramsone.put("award_pic_path3", "");
            paramsone.put("award_pic_path4", "");
            paramsone.put("award_pic_path5", "");
            paramsone.put("remark", "");//备注

            if (paramsone.toString().equals("{}")) {
                return;
            }
            params.put("params", paramsone.toString());
            params.put("sign", genPackageSignUser(params));
        } catch (JSONException e) {

        }
        requestData("/openapi/goods", requestId, params);
    }

    /**
     * 会员信息页面
     */

    public void requestMembersCount(int requestId) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/statistic/store/monthly_dynamic", requestId, params);
    }


    /**
     * 验证优惠券
     *
     * @param sku_code  优惠券的码
     */
    public void requestCouponValidate(int requestId, String sku_code) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        params.put("service", "goods.couponValidate");
        JSONObject paramsone = new JSONObject();
        try {

            paramsone.put("member_id", MainActivity.member_id);
            paramsone.put("sku_code", sku_code);
        } catch (JSONException e) {

        }

        if (paramsone.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsone.toString());
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/goods", requestId, params);
    }

    /**
     * 查询优惠券信息
     */
    public void requestValidateFindForStores(int requestId, String sku_code) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        params.put("service", "goods.couponValidateFindForStores");
        JSONObject paramsone = new JSONObject();
        try {

            paramsone.put("member_id", MainActivity.member_id);
            paramsone.put("sku_code", sku_code);
        } catch (JSONException e) {

        }

        if (paramsone.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsone.toString());
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/goods", requestId, params);
    }

    /**
     * 4.22	手机号登录授权注册
     */
    public void requestMobileLoginReg(int requestId) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/base/mobile_login_reg", requestId, params);
    }

    /**
     * 获取惠易定版本
     */
    public void requestGetHYDVersion(int requestId, String user_token) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", user_token);
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/hyd/get_version", requestId, params);
    }

    /**
     * 退出接口 清除token
     */
    public void requestLogout(int requestId) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/user/logout", requestId, params);
    }

    /**
     * @param goods_code 商品code
     * @param goods_url  商品url
     * @param amount     金额
     * @param member_id  消费者会员id
     */
    public void requestFreeGet(int requestId, String goods_code, String goods_url, String amount, String member_id, String card_no) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject paramsone = new JSONObject();
        try {
            paramsone.put("goods_code", goods_code);
            paramsone.put("goods_url", goods_url);
            paramsone.put("amount", amount);
            paramsone.put("card_no", card_no);
            paramsone.put("member_id", member_id);
            Log.v("zyl", "requestFreeGet stores_name:" + Stores.stores_name);
            paramsone.put("stores_name", Stores.stores_name);
        } catch (JSONException e) {

        }
        params.put("service", "order.consumerFreeGetRecordCreate");
        params.put("params", paramsone.toString());
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/opsorder", requestId, params);
    }

    /**
     * 通过手机号查询消费者的memberId
     */
    public void requestQueryConsumerMememberId(int requestId, String mobile) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        params.put("mobile", mobile);
        params.put("member_type_key", "consumer");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/user/get_member_id_by_mobile", requestId, params);
    }

    /**
     * 取消活动
     */
    public void requestCancelActivity(int requestId, String activityId, String remark) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject pageObj = new JSONObject();
        try {
            pageObj.put("activity_id", activityId);
            pageObj.put("remark", remark);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        params.put("service", "goods.ldActivityCancel");
        params.put("params", pageObj.toString());
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/goods", requestId, params);
    }

    /**
     * 一元购
     */
    public void requestOneYuanQuery(int requestId, String stores_id, int page_no) {
        AjaxParams params = new AjaxParams();
        JSONObject pageObj = new JSONObject();
        try {
            pageObj.put("page_no", page_no + "");
            pageObj.put("page_size", "15");
        } catch (JSONException e) {
            e.printStackTrace();
        }

        params.put("page", pageObj.toString());
        params.put("user_token", MainActivity.user_token);
        params.put("service", "goods.ldActivityForStorePageFind");
        JSONObject paramsone = new JSONObject();
        try {
            paramsone.put("stores_id", stores_id);
        } catch (JSONException e) {

        }

        if (paramsone.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsone.toString());
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/goods", requestId, params);
    }

    /**
     * 一元购详情
     */
    public void requestOneYuan_DetailsQuery(int requestId, String activity_id, int page_no) {
        AjaxParams params = new AjaxParams();
        JSONObject pageObj = new JSONObject();
        try {
            pageObj.put("page_no", page_no + "");
            pageObj.put("page_size", "20");
        } catch (JSONException e) {
            e.printStackTrace();
        }

        params.put("page", pageObj.toString());
        params.put("user_token", MainActivity.user_token);
        params.put("service", "goods.ldActivityProcessForStorePageFind");
        JSONObject paramsone = new JSONObject();
        try {
            paramsone.put("activity_id", activity_id);
        } catch (JSONException e) {

        }

        if (paramsone.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsone.toString());
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/goods", requestId, params);
    }

    /**
     * @param activity_id   活动id
     * @param consumer_id   消费者id
     * @param draw_code     中奖id
     * @param activity_type 类型 区分定时开 刮刮乐 摇一摇
     * @param process_id    中奖id
     *                      验证中奖二维码
     */
    public void requestValidateCode(int requestId, String stores_id, String activity_id, String consumer_id, String draw_code, String activity_type, String process_id) {
        Log.v("zyl", "requestValidateCode");
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject pageObj = new JSONObject();
        try {
            pageObj.put("activity_id", activity_id);
            pageObj.put("consumer_id", consumer_id);
            pageObj.put("stores_id", stores_id);
            pageObj.put("draw_code", draw_code);
            pageObj.put("activity_type", activity_type);
            pageObj.put("process_id", process_id);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        if (pageObj.toString().equals("{}")) {
            return;
        }
        params.put("params", pageObj.toString());
        params.put("service", "goods.ldActivityValidate");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/goods", requestId, params);
    }

    /**
     * 查询兑奖信息
     */
    public void requestValidateFind(int requestId, String activity_type, String stores_id, String activity_id, String process_id, String luck_code) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject pageObj = new JSONObject();
        try {
            pageObj.put("activity_type", activity_type);
            pageObj.put("stores_id", stores_id);
            pageObj.put("activity_id", activity_id);
            pageObj.put("process_id", process_id);
            pageObj.put("luck_code", luck_code);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        if (pageObj.toString().equals("{}")) {
            return;
        }
        params.put("params", pageObj.toString());
        params.put("service", "goods.ldActivityValidateFind");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/goods", requestId, params);
    }

    /**
     * 核销 现金券。
     */
    public void requestScanningCashCoupon(int requestId, String cashCouponCode) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("seller_id", Stores.member_id);
            jsonObject.put("cashCouponCode", cashCouponCode);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        params.put("params", jsonObject.toString());
        params.put("service", "consumer.hebaoUseCashCoupon");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/finance", requestId, params);
    }

    /**
     * 获取客服信息
     */
    public void requestGetHelper(int requestId) {
        try {
            AjaxParams params = new AjaxParams();
            params.put("app_token", MainActivity.app_token);
            JSONObject pageObj = new JSONObject();
            pageObj.put("stores_id", MainActivity.member_id);
            if (pageObj.toString().equals("{}")) {
                return;
            }
            params.put("params", pageObj.toString());
            params.put("service", "member.storeAssistantFind");
            params.put("sign", genPackageSign(params));
            requestData("/openapi/member", requestId, params);
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    /**
     * 提交客服评价
     */
    public void requestEvaluateService(int requestId, String assistant_id, String evaluation_by,
                                       String criteria_val1, String criteria_val2, String criteria_val3, String criteria_val4,
                                       String criteria_val5
    ) {

        try {
            AjaxParams params = new AjaxParams();
            params.put("app_token", MainActivity.app_token);
            JSONObject pageObj = new JSONObject();

            pageObj.put("assistant_id", assistant_id);/** 店东助手标识 **/
            pageObj.put("stores_id", MainActivity.member_id);/** 门店标识 **/
            pageObj.put("evaluation_by", evaluation_by);/** 评估人标识 **/
            pageObj.put("criteria_val1", criteria_val1); /** 指标项1（响应及时）**/
            pageObj.put("criteria_val2", criteria_val2); /** 指标项2（专业技能）**/
            pageObj.put("criteria_val3", criteria_val3);   /** 指标项3（品行端正）**/
            pageObj.put("criteria_val4", criteria_val4);    /** 指标项4（积极主动）**/
            pageObj.put("criteria_val5", criteria_val5);   /** 指标项5（工作成果）**/
            if (pageObj.toString().equals("{}")) {
                return;
            }
            params.put("params", pageObj.toString());
            params.put("service", "member.assistantEvaluationCreate");
            params.put("sign", genPackageSign(params));
            requestData("/openapi/member", requestId, params);
        } catch (JSONException e) {
            e.printStackTrace();
        }
    }

    /**
     * 旧的我要批买单订单查询（废弃）
     */
//    public void requestBuyOrderQuery(int requestId, String page_no, String page_size) {
//        Log.v("zyl", "-------usertoken:" + MainActivity.user_token);
//        AjaxParams params = new AjaxParams();
//
//        params.put("user_token", MainActivity.user_token);
//        JSONObject pageObj = new JSONObject();
//        try {
//            pageObj.put("page_no", page_no + "");
//            pageObj.put("page_size", page_size + "");
//        } catch (JSONException e) {
//            e.printStackTrace();
//        }
//
//        JSONObject paramsObj = new JSONObject();
//        try {
//            paramsObj.put("member_id", MainActivity.member_id);
//        } catch (JSONException e) {
//            e.printStackTrace();
//        }
//        params.put("page", pageObj.toString());
//        params.put("params", paramsObj.toString());
//        params.put("service", "order.psOrderListPageFind");
//        params.put("user_token", MainActivity.user_token);
//        params.put("sign", genPackageSignUser(params));
//        requestData("/openapi/opsorder", requestId, params);
//    }

    /**
     * 预售订单查询
     */
    public void requestBuyOrderQuery(int requestId, String page_no, String page_size) {
        Log.v("zyl", "-------usertoken:" + MainActivity.user_token);
        AjaxParams params = new AjaxParams();

        params.put("user_token", MainActivity.user_token);
        JSONObject pageObj = new JSONObject();
        try {
            pageObj.put("page_no", page_no + "");
            pageObj.put("page_size", page_size + "");
        } catch (JSONException e) {
            e.printStackTrace();
        }

        JSONObject paramsObj = new JSONObject();
        try {
            paramsObj.put("member_id", MainActivity.member_id);
            paramsObj.put("member_type_key", "stores");
        } catch (JSONException e) {
            e.printStackTrace();
        }
        params.put("page", pageObj.toString());
        if (pageObj.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsObj.toString());
        params.put("service", "order.psGroupOrderForStoresListPageFind");
        params.put("user_token", MainActivity.user_token);
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/opsorder", requestId, params);
    }

    /**
     * 特卖 掌上便利店订单统计
     */
    public void requestSpecialSell_ZSBLDQuery(int requestId) {
        AjaxParams params = new AjaxParams();

        params.put("user_token", MainActivity.user_token);

        JSONObject paramsObj = new JSONObject();
        try {
            paramsObj.put("stores_id", MainActivity.member_id);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        params.put("params", paramsObj.toString());
        params.put("service", "pcOrder.stores.pcOrderSellCountForStoresSale");
        params.put("user_token", MainActivity.user_token);
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/opsorder", requestId, params);
    }

    /**
     * 特卖 自动售货机订单统计
     */
    public void requestSpecialSell_AutoSellQuery(int requestId) {
        AjaxParams params = new AjaxParams();

        params.put("user_token", MainActivity.user_token);

        JSONObject paramsObj = new JSONObject();
        try {
            paramsObj.put("stores_id", MainActivity.member_id);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        params.put("params", paramsObj.toString());
        params.put("service", "order.autoSellCountForStoresSale");
        params.put("user_token", MainActivity.user_token);
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/opsorder", requestId, params);
    }

    /**
     * 特卖 伙拼团订单统计(店东特卖)
     */
    public void requestSpecialSell_HPTQuery(int requestId) {
        AjaxParams params = new AjaxParams();

        params.put("user_token", MainActivity.user_token);

        JSONObject paramsObj = new JSONObject();
        try {
            paramsObj.put("stores_id", MainActivity.member_id);
        } catch (JSONException e) {
            e.printStackTrace();
        }

        params.put("params", paramsObj.toString());
        params.put("service", "tsOrder.stores.tsOrderCountForStoresSale");
        params.put("user_token", MainActivity.user_token);
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/opsorder", requestId, params);
    }

    /**
     * 特卖 商品便利店上架商品数量
     */
    public void requestSpecialSell_SellGoodsCountForStoresSaleQuery(int requestId) {
        AjaxParams params = new AjaxParams();

        params.put("user_token", MainActivity.user_token);

        JSONObject paramsObj = new JSONObject();
        try {
            paramsObj.put("stores_id", MainActivity.member_id);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        params.put("params", paramsObj.toString());
        params.put("service", "storesGoods.stores.isSellGoodsCountForStoresSale");
        params.put("user_token", MainActivity.user_token);
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/goods", requestId, params);
    }

    /**
     * 特卖 我要批
     */
    public void requestSpecialSell_WYPQuery(int requestId) {
        AjaxParams params = new AjaxParams();

        params.put("user_token", MainActivity.user_token);

        JSONObject paramsObj = new JSONObject();
        try {
            paramsObj.put("stores_id", MainActivity.member_id);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        params.put("params", paramsObj.toString());
        params.put("service", "order.wypCooperationStoresSaleCount");
        params.put("user_token", MainActivity.user_token);
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/opsorder", requestId, params);
    }

    /**
     * 特卖 社区导购统计
     */
    public void requestSpecialSell_saleAssistantSaleCountQuery(int requestId) {
        AjaxParams params = new AjaxParams();

        params.put("user_token", MainActivity.user_token);

        JSONObject paramsObj = new JSONObject();
        try {
            paramsObj.put("stores_id", MainActivity.member_id);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        params.put("params", paramsObj.toString());
        params.put("service", "order.saleAssistantSaleCount");
        params.put("user_token", MainActivity.user_token);
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/opsorder", requestId, params);
    }

    /**
     * 店铺预览 获取推荐的特色产品
     */
    public void requestRecommendedFeatureGood(int requestId) {
        AjaxParams params = new AjaxParams();

        params.put("app_token", MainActivity.app_token);

        JSONObject paramsObj = new JSONObject();
        try {
            paramsObj.put("store_id", MainActivity.member_id);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        params.put("params", paramsObj.toString());
        params.put("service", "goods.recommendItemStoreForConsumerListPageFind");
        params.put("sign", genPackageSign(params));
        requestData("/openapi/goods", requestId, params);
    }

    /**
     * 店铺预览 获取活动数量
     */
    public void requestActivityAmount(int requestId) {
        AjaxParams params = new AjaxParams();

        params.put("app_token", MainActivity.app_token);

        JSONObject paramsObj = new JSONObject();
        try {
            paramsObj.put("stores_id", MainActivity.member_id);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        params.put("params", paramsObj.toString());
        params.put("service", "goods.storesActivityCount");
        params.put("sign", genPackageSign(params));
        requestData("/openapi/goods", requestId, params);
    }

    /**
     * 店铺预览 获取特色产品
     */
    public void requestFeatureGood(int requestId,String categroy_id) {
        AjaxParams params = new AjaxParams();

        params.put("app_token", MainActivity.app_token);

        JSONObject paramsObj = new JSONObject();
        try {
            paramsObj.put("store_id", MainActivity.member_id);
            if(!"全部".equals(categroy_id)) {
                paramsObj.put("category_id", categroy_id);
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
        params.put("params", paramsObj.toString());
        params.put("service", "goods.itemStorePageFindForConsumer");
        params.put("sign", genPackageSign(params));
        requestData("/openapi/goods", requestId, params);
    }

    /**
     * 店铺预览 获取产品分类
     */
    public void requestFeatureGood_TYPE(int requestId) {
        AjaxParams params = new AjaxParams();

        params.put("app_token", MainActivity.app_token);

        JSONObject paramsObj = new JSONObject();
        try {
            paramsObj.put("store_id", MainActivity.member_id);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        params.put("params", paramsObj.toString());
        params.put("service", "goods.itemStoreGroupTypeForConsumerFind");
        params.put("sign", genPackageSign(params));
        requestData("/openapi/goods", requestId, params);
    }

    /**
     * 店铺预览 获取店铺信息
     */
    public void requestStoreDetail(int requestId) {
        AjaxParams params = new AjaxParams();

        params.put("app_token", MainActivity.app_token);

        JSONObject paramsObj = new JSONObject();
        try {
            paramsObj.put("stores_id", MainActivity.member_id);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        params.put("params", paramsObj.toString());
        params.put("service", "member.storeDetailFind");
        params.put("sign", genPackageSign(params));
        requestData("/openapi/member", requestId, params);
    }

    /**
     * 买单查询新接口
     */
    public void requestwypOrderList(int requestId, String page_no, String page_size) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject pageObj = new JSONObject();
        try {
            pageObj.put("page_no", page_no + "");
            pageObj.put("page_size", page_size + "");
        } catch (JSONException e) {
            e.printStackTrace();
        }

        JSONObject paramsObj = new JSONObject();
        try {
            paramsObj.put("member_id", MainActivity.member_id);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        params.put("page", pageObj.toString());
        if (pageObj.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsObj.toString());
        params.put("service", "order.wypOrderListForStoresPageFind");
        params.put("user_token", MainActivity.user_token);
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/opsorder", requestId, params);
    }

    /**
     * 根据提货码搜索
     */
    public void requestByloadedCodeForStoresFind(int requestId, String loaded_code) {
        AjaxParams params = new AjaxParams();
        JSONObject paramsObj = new JSONObject();
        try {
            paramsObj.put("loaded_code", loaded_code);
            paramsObj.put("stores_id", MainActivity.member_id);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        if (paramsObj.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsObj.toString());
        params.put("service", "order.orderByloadedCodeForStoresFind");
        params.put("user_token", MainActivity.user_token);
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/opsorder", requestId, params);
    }

    /**
     * 惠商驿站编辑(废弃 不要调用 ，有问题，找丁戈)
     *
     * @param is_stage_hpt 是否打开伙拼团
     * @param is_stage_hyd 是否打开惠易定
     */
    public void requeststageStoresEdit(int requestId, String is_stage_hpt, String is_stage_hyd) {
//        AjaxParams params = new AjaxParams();
//        JSONObject paramsObj = new JSONObject();
//        try {
//            paramsObj.put("is_stage_hpt", is_stage_hpt);
//            paramsObj.put("is_stage_hyd", is_stage_hyd);
//            paramsObj.put("stores_id", MainActivity.member_id);
//        } catch (JSONException e) {
//            e.printStackTrace();
//        }
//        if (paramsObj.toString().equals("{}")) {
//            return;
//        }
//        params.put("params", paramsObj.toString());
//        params.put("service", "stores.stores.stageStoresEdit");
//        params.put("user_token", MainActivity.user_token);
//        params.put("sign", genPackageSignUser(params));
//        requestData("/openapi/member", requestId, params);
    }

    /**
     * 惠商驿站查询
     */
    public void requeststageStoresFind(int requestId) {
        AjaxParams params = new AjaxParams();
        JSONObject paramsObj = new JSONObject();
        try {
            paramsObj.put("stores_id", MainActivity.member_id);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        if (paramsObj.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsObj.toString());
        params.put("service", "stores.stores.stageStoresFind");
        params.put("user_token", MainActivity.user_token);
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/member", requestId, params);
    }

    /**
     * 新任务列表接口
     */
    public void requestNewTaskList(int requestId, String page_no, String page_size) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject pageObj = new JSONObject();
        try {
            pageObj.put("page_no", page_no + "");
            pageObj.put("page_size", page_size + "");
        } catch (JSONException e) {
            e.printStackTrace();
        }

        JSONObject paramsObj = new JSONObject();
        try {
            paramsObj.put("member_id", MainActivity.member_id);
            paramsObj.put("member_type_key", "stores");
            paramsObj.put("area_id", Stores.area_id);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        params.put("page", pageObj.toString());
        if (pageObj.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsObj.toString());
        params.put("service", "odTask.stores.odTaskNewListPageFind");
        params.put("user_token", MainActivity.user_token);
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/opsorder", requestId, params);
    }


    /**
     * 任务待提交列表接口
     */
    public void requestTaskOrtherList(int requestId, String page_no, String page_size, String status) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject pageObj = new JSONObject();
        try {
            pageObj.put("page_no", page_no + "");
            pageObj.put("page_size", page_size + "");
        } catch (JSONException e) {
            e.printStackTrace();
        }

        JSONObject paramsObj = new JSONObject();
        try {
            paramsObj.put("member_id", MainActivity.member_id);
            paramsObj.put("member_type_key", "stores");
            if ("closed".equals(status)) {
                paramsObj.put("status", "closed,aborted");
            } else {
                paramsObj.put("status", status);
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
        params.put("page", pageObj.toString());
        if (pageObj.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsObj.toString());
        params.put("service", "odTask.stores.odTaskProcessingListPageFind");
        params.put("user_token", MainActivity.user_token);
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/opsorder", requestId, params);
    }

    /**
     * 添加商品
     */
    public void requestAddGoods(int requestId, String barcode, String name, String spec, String stock, String price, String cost, String stock_call,
                                String vender, String returnMoney, String shelf_life, String expiration_date, String dealer,
                                String swWeight, String swTimeCall, String swToCashier, String swToLocalLife, String swRecommend, String swDiscount,
                                String swStopSell, String docId, String category_id, String item_id, String item_code, String item_name, String desc1, String image_detail) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);

        JSONObject paramsObj = new JSONObject();
        try {
            paramsObj.put("store_id", MainActivity.member_id);
            paramsObj.put("stores_name", Stores.stores_name);
            paramsObj.put("barcode", barcode);
            paramsObj.put("item_name", name);
            paramsObj.put("specification", spec);
            paramsObj.put("sale_qty", stock);
            paramsObj.put("market_price", price);
            paramsObj.put("cost_price", cost);
            paramsObj.put("stock_warning", stock_call);
            paramsObj.put("manufacturer", vender);
            paramsObj.put("rebate", returnMoney);
            paramsObj.put("durability_period", shelf_life);
            paramsObj.put("production_date", expiration_date);
            paramsObj.put("supplier", dealer);
            paramsObj.put("is_weighed", swWeight);
            paramsObj.put("expired_warning", swTimeCall);   //临期预警
            paramsObj.put("is_show", swToCashier);
            paramsObj.put("is_sell", swToLocalLife);
            paramsObj.put("is_recommend", swRecommend);
            paramsObj.put("is_discount", swDiscount);
            paramsObj.put("is_offline", swStopSell);
            paramsObj.put("image_info", docId);
            paramsObj.put("category_id", category_id);
            paramsObj.put("brand_id", "自营");
            paramsObj.put("pack", "");
            paramsObj.put("desc1", desc1);
            paramsObj.put("image_detail", image_detail);
            paramsObj.put("weight", "0");
            paramsObj.put("vip_price", price);
            if (!TextUtils.isEmpty(item_id)) {
                paramsObj.put("item_id", item_id);
            }
            if (!TextUtils.isEmpty(item_code)) {
                paramsObj.put("item_code", item_code);
            }
            if (!TextUtils.isEmpty(item_name)) {
                paramsObj.put("item_name", item_name);
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
        if (paramsObj.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsObj.toString());
        params.put("service", "storeItem.stores.itemStoreCreate");
        params.put("user_token", MainActivity.user_token);
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/goods", requestId, params);
    }

    /**
     * @param owncode         自编码
     * @param barcode         条码
     * @param quick_code      助记码
     * @param goods_name      商品名称
     * @param category        品类
     * @param manufacturer    生产厂家
     * @param mSaleUnit       销售单位
     * @param mPurchaseUnit   采购单位
     * @param mMinPackageUnit 最小包装单位
     * @param conversion      换算关系
     * @param swWeight        是否称重计量(Y/N)
     * @param shelf_life      保质期
     * @param clw             陈列位
     * @param price           售价
     * @param returnMoney     返现
     * @param discount        优惠折扣（0.00~1.00）
     * @param time_call       临期预警
     * @param stock_call      库存预警
     * @param swToAd          是否推荐
     * @param swToCashier     是否显示到收银台
     * @param swToLocalLife   是否网店销售
     * @param swDiscount      否允许促销活动
     * @param pic_detail_info 图片信息
     */
    public void requestAddGood(int requestId, String owncode,String barcode, String quick_code, String goods_name, String category, String manufacturer, String mSaleUnit, String mPurchaseUnit, String mMinPackageUnit,
                               String conversion, String swWeight, String shelf_life, String clw, String price, String returnMoney, String discount, String time_call,
                               String stock_call, String swToAd, String swToCashier, String swToLocalLife, String swDiscount, String pic_detail_info, String pic_info
    ) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);

        JSONObject paramsObj = new JSONObject();
        try {
            paramsObj.put("stores_id", MainActivity.member_id);
            paramsObj.put("goods_code", owncode);
            paramsObj.put("barcode", barcode);
            paramsObj.put("quick_code", quick_code);
            paramsObj.put("goods_name", goods_name);
            paramsObj.put("category", category);
            //厂家/品牌不为空时才提交
            if(!TextUtils.isEmpty(manufacturer)){
                paramsObj.put("manufacturer", manufacturer);
            }
            paramsObj.put("sale_unit", mSaleUnit);
            paramsObj.put("purchase_unit", mPurchaseUnit);
            paramsObj.put("min_pack_unit", mMinPackageUnit);
            paramsObj.put("conversion_relation", conversion);
            paramsObj.put("is_weighed", swWeight);
            //保质期不为空时才提交
            if(!TextUtils.isEmpty(shelf_life)){
                paramsObj.put("durability_period", shelf_life);
            }
            //陈列位不为空时才提交
            if(!TextUtils.isEmpty(clw)){
                paramsObj.put("warehouse", clw);
            }
            paramsObj.put("expired_warning", time_call);
            paramsObj.put("market_price", price);
            paramsObj.put("cost_price", "0.00");//售价
            paramsObj.put("gross_profit", "0.00");//毛利
            paramsObj.put("rebate", returnMoney);
            paramsObj.put("discount", discount);
            paramsObj.put("stock_warning", stock_call);
            paramsObj.put("is_recommend", swToAd);
            paramsObj.put("is_show", swToCashier);
            paramsObj.put("is_sell", swToLocalLife);
            paramsObj.put("is_activity", swDiscount);
            paramsObj.put("stores_name", Stores.stores_name);
            paramsObj.put("stores_service_tel", Stores.contact_tel);
            paramsObj.put("pic_detail_info", pic_detail_info);
            paramsObj.put("image_info", pic_info);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        if (paramsObj.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsObj.toString());
        params.put("service", "storesGoods.stores.goodsCreate");
        params.put("user_token", MainActivity.user_token);
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/goods", requestId, params);
    }

    /**
     * @param stores_goods_id stores_goods_id
     * @param owncode         自编码
     * @param barcode         条码
     * @param quick_code      助记码
     * @param goods_name      商品名称
     * @param category        品类
     * @param manufacturer    生产厂家
     * @param mSaleUnit       销售单位
     * @param mPurchaseUnit   采购单位
     * @param mMinPackageUnit 最小包装单位
     * @param conversion      换算关系
     * @param swWeight        是否称重计量(Y/N)
     * @param shelf_life      保质期
     * @param clw             陈列位
     * @param price           售价
     * @param returnMoney     返现
     * @param discount        优惠折扣（0.00~1.00）
     * @param time_call       临期预警
     * @param stock_call      库存预警
     * @param swToAd          是否推荐
     * @param swToCashier     是否显示到收银台
     * @param swToLocalLife   是否网店销售
     * @param swDiscount      否允许促销活动
     * @param pic_detail_info 图片信息
     */
    public void requestEditGood(int requestId, String stores_goods_id,String owncode,String barcode, String quick_code, String goods_name, String category, String manufacturer, String mSaleUnit, String mPurchaseUnit, String mMinPackageUnit,
                               String conversion, String swWeight, String shelf_life, String clw, String price, String returnMoney, String discount, String time_call,
                               String stock_call, String swToAd, String swToCashier, String swToLocalLife, String swDiscount, String pic_detail_info
    ) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);

        JSONObject paramsObj = new JSONObject();
        try {
            paramsObj.put("stores_goods_id",stores_goods_id);
            paramsObj.put("stores_id", MainActivity.member_id);
            paramsObj.put("goods_code", owncode);
            paramsObj.put("barcode", barcode);
            if(TextUtils.isEmpty(quick_code)){
                quick_code = barcode.substring(barcode.length() - 4);
            }
            paramsObj.put("quick_code", quick_code);
            paramsObj.put("goods_name", goods_name);
            paramsObj.put("category", category);
            //厂家/品牌不为空时才提交
            if(!TextUtils.isEmpty(manufacturer)){
                paramsObj.put("manufacturer", manufacturer);
            }
            paramsObj.put("sale_unit", mSaleUnit);
            paramsObj.put("purchase_unit", mPurchaseUnit);
            paramsObj.put("min_pack_unit", mMinPackageUnit);
            paramsObj.put("conversion_relation", conversion);
            paramsObj.put("is_weighed", swWeight);
            //保质期不为空时才提交
            if(!TextUtils.isEmpty(shelf_life)){
                paramsObj.put("durability_period", shelf_life);
            }
            //陈列位不为空时才提交
            if(!TextUtils.isEmpty(clw)){
                paramsObj.put("warehouse", clw);
            }
            paramsObj.put("expired_warning", time_call);
            paramsObj.put("market_price", price);
            paramsObj.put("cost_price", "0.00");//售价
            paramsObj.put("gross_profit", "0.00");//毛利
            paramsObj.put("rebate", returnMoney);
            paramsObj.put("discount", discount);
            paramsObj.put("stock_warning", stock_call);
            paramsObj.put("is_recommend", swToAd);
            paramsObj.put("is_show", swToCashier);
            paramsObj.put("is_sell", swToLocalLife);
            paramsObj.put("is_activity", swDiscount);
            paramsObj.put("stores_name", Stores.stores_name);
            paramsObj.put("stores_service_tel", Stores.contact_tel);
            paramsObj.put("pic_detail_info", pic_detail_info);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        if (paramsObj.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsObj.toString());
        params.put("service", "storesGoods.stores.goodsEdit");
        params.put("user_token", MainActivity.user_token);
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/goods", requestId, params);
    }

    /**
     * @param qty             数量
     * @param cost_price      进价
     * @param production_date 生产日期
     * @param supplier        经销商
     */
    public void requestStockReplenish(int requestId, String qty, String  cost_price, String production_date, String supplier, String stores_goods_id
    ) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject paramsObj = new JSONObject();
        try {
            paramsObj.put("stores_goods_id", stores_goods_id);
            paramsObj.put("qty", qty);
            paramsObj.put("cost_price",  cost_price);
            if (!TextUtils.isEmpty(production_date)) {
                paramsObj.put("production_date", production_date);
            }
            if (!TextUtils.isEmpty(supplier)) {
                paramsObj.put("supplier", supplier);
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
        if (paramsObj.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsObj.toString());
        params.put("service", "storesGoods.stores.stockReplenish");
        params.put("user_token", MainActivity.user_token);
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/goods", requestId, params);
    }

    /**
     * 是否停止销售
     */
    public void requestGoodsEditIsoffline(int requestId, String is_offline, String stores_goods_id) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject paramsObj = new JSONObject();
        try {
            paramsObj.put("stores_goods_id", stores_goods_id);
            paramsObj.put("is_offline", is_offline);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        if (paramsObj.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsObj.toString());
        params.put("service", "storesGoods.stores.goodsSaleStatusEdit");
        params.put("user_token", MainActivity.user_token);
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/goods", requestId, params);
    }

    public void requestEdditGoods(int requestId, String barcode, String name, String spec, String stock, String price, String cost, String stock_call,
                                  String vender, String returnMoney, String shelf_life, String expiration_date, String dealer,
                                  String swWeight, String swTimeCall, String swToCashier, String swToLocalLife, String swRecommend, String swDiscount,
                                  String swStopSell, String docId, String category_id, String item_store_id, String desc1, String image_detail) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);

        JSONObject paramsObj = new JSONObject();
        try {
            paramsObj.put("store_id", MainActivity.member_id);
            paramsObj.put("barcode", barcode);
            paramsObj.put("item_name", name);
            paramsObj.put("specification", spec);
            paramsObj.put("sale_qty", stock);
            paramsObj.put("market_price", price);
            paramsObj.put("cost_price", cost);
            paramsObj.put("stock_warning", stock_call);
            paramsObj.put("manufacturer", vender);
            paramsObj.put("rebate", returnMoney);
            paramsObj.put("durability_period", shelf_life);
            paramsObj.put("production_date", expiration_date);
            paramsObj.put("supplier", dealer);
            paramsObj.put("is_weighed", swWeight);
            //临期预警
            paramsObj.put("expired_warning", swTimeCall);
            paramsObj.put("is_show", swToCashier);
            paramsObj.put("is_sell", swToLocalLife);
            //是否推荐
            paramsObj.put("is_recommend", swRecommend);
            paramsObj.put("is_discount", swDiscount);
            paramsObj.put("is_offline", swStopSell);
            paramsObj.put("image_info", docId);
            paramsObj.put("category_id", category_id);
            paramsObj.put("brand_id", "自营");
            paramsObj.put("pack", "");
            paramsObj.put("desc1", desc1);
            paramsObj.put("image_detail", image_detail);
            paramsObj.put("weight", "0");
            paramsObj.put("vip_price", price);
            paramsObj.put("item_store_id", item_store_id);

        } catch (JSONException e) {
            e.printStackTrace();
        }
        if (paramsObj.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsObj.toString());
        params.put("service", "storeItem.stores.itemStoreEdit");
        params.put("user_token", MainActivity.user_token);
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/goods", requestId, params);
    }


    /**
     * 便利店订单
     */
    public void requestSellOrderQuery(int requestId, String page_no, String page_size, String loaded_code) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject pageObj = new JSONObject();
        try {
            pageObj.put("page_no", page_no + "");
            pageObj.put("page_size", page_size + "");
        } catch (JSONException e) {
            e.printStackTrace();
        }
        JSONObject paramsObj = new JSONObject();
        try {
            paramsObj.put("stores_id", MainActivity.member_id);
            if (!TextUtils.isEmpty(loaded_code)) {
                paramsObj.put("loaded_code", loaded_code);
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
        if (!TextUtils.isEmpty(page_no) && !TextUtils.isEmpty(page_size)) {
            params.put("page", pageObj.toString());
        }

        if (paramsObj.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsObj.toString());
        params.put("service", "order.pcOrderDetailPageFind");
        params.put("user_token", MainActivity.user_token);
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/opsorder", requestId, params);
    }


    /**
     * 获取订单数量
     */
    public void requestOrderCount(int requestId) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
//        JSONObject pageObj = new JSONObject();
//        try {
//            pageObj.put("page_no", page_no+"" );
//            pageObj.put("page_size", page_size+"");
//        } catch (JSONException e) {
//            e.printStackTrace();
//        }

        JSONObject paramsObj = new JSONObject();
        try {
            paramsObj.put("stores_id", MainActivity.member_id);
        } catch (JSONException e) {
            e.printStackTrace();
        }
//        params.put("page",pageObj.toString());
        if (paramsObj.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsObj.toString());
        params.put("service", "order.pcOrderPayedNum");
        params.put("user_token", MainActivity.user_token);
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/opsorder", requestId, params);
    }


    /**
     * 发起伙拼团
     *
     * @param qty_limit    成团数量
     * @param closing_time 截止时间
     * @param retail_price 团购价格
     */
    public void requestCreateHPT(int requestId, String qty_limit, String closing_time, String retail_price, BookedBean bookedBean) {
        AjaxParams params = new AjaxParams();
        JSONObject jsonGoods = new JSONObject();
        try {
            jsonGoods.put("goods_id", bookedBean.getGoods_id());
            jsonGoods.put("goods_code", bookedBean.getGoods_code());
            jsonGoods.put("goods_title", bookedBean.getTitle());
            jsonGoods.put("sale_price", bookedBean.getDiscount_price());
            jsonGoods.put("discount_fee", bookedBean.getDiscount_price());
//            jsonGoods.put("discount_fee", bookedBean.getDiscount_price());
//            jsonGoods.put("discount_fee", bookedBean.getDiscount_price());

        } catch (Exception e) {
        }


        JSONObject paramsObj = new JSONObject();
        try {
            paramsObj.put("desc1", bookedBean.getDesc1());
            paramsObj.put("member_id", MainActivity.member_id);
            paramsObj.put("member_type_key", "stores");
            paramsObj.put("stores_name", Stores.stores_name);
            paramsObj.put("delivery_address", Stores.area_desc + Stores.address);
            paramsObj.put("contact_tel", Stores.contact_tel);
            paramsObj.put("contact_person", Stores.contact_person);
            paramsObj.put("retail_price", retail_price);
            paramsObj.put("qty_limit", qty_limit);
            paramsObj.put("closing_time", closing_time);
            paramsObj.put("ps_goods", jsonGoods.toString());
        } catch (JSONException e) {
            e.printStackTrace();
        }
        if (paramsObj.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsObj.toString());
        params.put("service", "order.initiateGroup");
        params.put("user_token", MainActivity.user_token);
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/opsorder", requestId, params);
    }

    /**
     * 查看伙拼团订单详情
     *
     * @param parent_order_id 订单id
     */
    public void requestHTPOrderDetails(int requestId, String parent_order_id) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject paramsObj = new JSONObject();
        try {
            paramsObj.put("parent_order_id", parent_order_id);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        if (paramsObj.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsObj.toString());
        params.put("service", "order.psGroupSubOrderForStoresListPageFind");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/opsorder", requestId, params);
    }


    /**
     * 领样
     */
    public void requestFreeOrderQuery(int requestId, String page_no, String page_size, String status) {

        if (TextUtils.isEmpty(MainActivity.user_token) | TextUtils.isEmpty(MainActivity.member_id)) {
            return;
        }
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject pageObj = new JSONObject();
        try {
            pageObj.put("page_no", page_no + "");
            pageObj.put("page_size", page_size + "");
        } catch (JSONException e) {
            e.printStackTrace();
        }
        JSONObject paramsObj = new JSONObject();
        try {
            paramsObj.put("member_id", MainActivity.member_id);
            if (!TextUtils.isEmpty(status)) {
                paramsObj.put("status", status);
            }

        } catch (JSONException e) {
            e.printStackTrace();
        }
        params.put("page", pageObj.toString());
        Log.v("zyl", "memberId:" + MainActivity.member_id);
        Log.v("zyl", "paramsObj.toString():" + paramsObj.toString());
        if (paramsObj.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsObj.toString());
        params.put("service", "order.fgOrderListPageFind");
        params.put("user_token", MainActivity.user_token);
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/opsorder", requestId, params);
    }

    /**
     * 翼支付
     */
    public void requestYiPay(int requestId, String barCode, String amount, String out_trade_no) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject paramsObj = new JSONObject();
        try {
            paramsObj.put("order_type_key", "DDLX_17");
            paramsObj.put("scan_flag", "new2");
            paramsObj.put("data_source", "SJLY_02");
            paramsObj.put("detail", "翼支付");
            paramsObj.put("amount", amount);
            paramsObj.put("out_trade_no", out_trade_no);
            paramsObj.put("flow_no", out_trade_no);
            paramsObj.put("payment_way_key", SettingData.PAYMENT_WAY_14);
            paramsObj.put("buyer_id", SettingData.meitianhui_buyer_id);
            paramsObj.put("seller_id", MainActivity.member_id);
            paramsObj.put("auth_code", barCode);
            paramsObj.put("out_trade_body", paramsObj.toString());
        } catch (JSONException e) {
            e.printStackTrace();
        }
        if (paramsObj.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsObj.toString());
        params.put("service", "finance.balancePay");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/finance", requestId, params);
    }
    /**
     * 和包支付
     */
    public void requestMobilePackagePay(int requestId, String barCode, String amount, String out_trade_no,String productName) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject paramsObj = new JSONObject();
        try {
            paramsObj.put("order_type_key", "DDLX_17");
            paramsObj.put("scan_flag", "new2");
            paramsObj.put("data_source", "SJLY_02");
            paramsObj.put("detail", "和包支付");
            paramsObj.put("productName", productName);
            paramsObj.put("amount", amount);
            paramsObj.put("out_trade_no", out_trade_no);
            paramsObj.put("flow_no", out_trade_no);
            paramsObj.put("payment_way_key", SettingData.PAYMENT_WAY_25);
            paramsObj.put("buyer_id", SettingData.meitianhui_buyer_id);
            paramsObj.put("seller_id", MainActivity.member_id);
            paramsObj.put("auth_code", barCode);
            paramsObj.put("out_trade_body", paramsObj.toString());
        } catch (JSONException e) {
            e.printStackTrace();
        }
        if (paramsObj.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsObj.toString());
        params.put("service", "finance.balancePay");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/finance", requestId, params);
//        requestData("/ops-finance/finance", requestId, params);
    }
    /**
     * 验证码收款
     */
    public void requestCodePay(int requestId, String amount, String out_trade_no, String buyer_id) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject paramsObj = new JSONObject();
        try {
            paramsObj.put("data_source", "SJLY_02");
            paramsObj.put("detail", "验证码支付");
            paramsObj.put("amount", amount);
            paramsObj.put("out_trade_no", out_trade_no);
            paramsObj.put("flow_no", out_trade_no);
            paramsObj.put("payment_way_key", SettingData.PAYMENT_WAY_05);
            paramsObj.put("buyer_id", buyer_id);
            paramsObj.put("seller_id", MainActivity.member_id);
            paramsObj.put("out_trade_body", paramsObj.toString());
        } catch (JSONException e) {
            e.printStackTrace();
        }
        if (paramsObj.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsObj.toString());
        params.put("service", "finance.balanceCashier");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/finance", requestId, params);
    }

    /**
     * 亲情卡收款
     */
    public void requestFamilyPay(int requestId, String member_id, String amount, String cardno, String out_trade_no) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject paramsObj = new JSONObject();
        try {
            paramsObj.put("data_source", "SJLY_02");
            paramsObj.put("detail", "亲情卡");
            paramsObj.put("amount", amount);
            paramsObj.put("out_trade_no", out_trade_no);
            paramsObj.put("flow_no", out_trade_no);
            paramsObj.put("payment_way_key", SettingData.PAYMENT_WAY_05);
            paramsObj.put("card_no", cardno);
            paramsObj.put("buyer_id", member_id);
            paramsObj.put("seller_id", MainActivity.member_id);
            paramsObj.put("out_trade_body", paramsObj.toString());
        } catch (JSONException e) {
            e.printStackTrace();
        }
        if (paramsObj.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsObj.toString());
        params.put("service", "finance.balanceCashier");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/finance", requestId, params);
    }

    /**
     * 收银扫码收款
     */
    public void requestScanPay(int requestId, String member_id, String amount, String out_trade_no, String security_code) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject paramsObj = new JSONObject();
        try {
            paramsObj.put("data_source", "SJLY_02");
            paramsObj.put("detail", "扫码支付");
            paramsObj.put("amount", amount);
            paramsObj.put("out_trade_no", out_trade_no);
            paramsObj.put("flow_no", out_trade_no);
            paramsObj.put("payment_way_key", SettingData.PAYMENT_WAY_05);
            paramsObj.put("buyer_id", member_id);
            paramsObj.put("seller_id", MainActivity.member_id);

            JSONObject jsonObject2 = new JSONObject();
            jsonObject2.put("security_code", security_code);
            jsonObject2.put("security_code_type", "P");//代表二维码是付款码
            jsonObject2.put("buyer_id", member_id);
            jsonObject2.put("seller_id", MainActivity.member_id);

            paramsObj.put("out_trade_body", jsonObject2.toString());
        } catch (JSONException e) {
            e.printStackTrace();
        }

        if (paramsObj.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsObj.toString());
        params.put("service", "finance.balanceCashier");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/finance", requestId, params);
    }


    public void requestTestPay(int requestId, String barCode, String amount) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject paramsObj = new JSONObject();
        try {
            paramsObj.put("data_source", "SJLY_02");
            paramsObj.put("body", "扫码收款");
            paramsObj.put("total_fee", amount);
            paramsObj.put("out_trade_no", IDUtil.getOutTradeNo());
            paramsObj.put("auth_code", barCode);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        if (paramsObj.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsObj.toString());
        params.put("service", "finance.wechatBarCodePay");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/finance", requestId, params);
    }

    /**
     * 微信收款
     */
    public void requestWeChatPay(int requestId, String barCode, String amount, String out_trade_no) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject paramsObj = new JSONObject();
        try {
            paramsObj.put("order_type_key", "DDLX_17");
            paramsObj.put("scan_flag", "new");
            paramsObj.put("data_source", SettingData.DATA_SOURCE);
            paramsObj.put("detail", "微信");
            paramsObj.put("amount", amount);
            paramsObj.put("out_trade_no", out_trade_no);
            paramsObj.put("flow_no", out_trade_no);
            paramsObj.put("payment_way_key", SettingData.PAYMENT_WAY_11);
            paramsObj.put("buyer_id", SettingData.meitianhui_buyer_id);
            paramsObj.put("seller_id", MainActivity.member_id);
            paramsObj.put("auth_code", barCode);
            paramsObj.put("out_trade_body", paramsObj.toString());
        } catch (JSONException e) {
            e.printStackTrace();
        }
        if (paramsObj.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsObj.toString());
        params.put("service", "finance.balancePay");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/finance", requestId, params);
    }

    /**
     * 支付宝收款
     */
    public void requestAlipay(int requestId, String barCode, String amount, String out_trade_no) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject paramsObj = new JSONObject();
        try {
            paramsObj.put("order_type_key", "DDLX_17");
            paramsObj.put("data_source", "SJLY_02");
            paramsObj.put("scan_flag", "new");
            paramsObj.put("detail", "支付宝");
            paramsObj.put("amount", amount);
            paramsObj.put("out_trade_no", out_trade_no);
            paramsObj.put("flow_no", out_trade_no);
            paramsObj.put("payment_way_key", SettingData.PAYMENT_WAY_10);
            paramsObj.put("buyer_id", SettingData.meitianhui_buyer_id);
            paramsObj.put("seller_id", MainActivity.member_id);
            paramsObj.put("auth_code", barCode);
            paramsObj.put("out_trade_body", paramsObj.toString());
        } catch (JSONException e) {
            e.printStackTrace();
        }
        if (paramsObj.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsObj.toString());
        params.put("service", "finance.balancePay");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/finance", requestId, params);
    }

    /**
     * 现金充值
     */
    public void requestMoneyPay(int requestId, String amount, String memberId, String seller_id) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject paramsObj = new JSONObject();
        try {
            paramsObj.put("data_source", "SJLY_02");
            paramsObj.put("detail", "现金充值");
            paramsObj.put("amount", amount);
            paramsObj.put("out_trade_no", IDUtil.getOutTradeNo());
            paramsObj.put("payment_way_key", SettingData.PAYMENT_WAY_05);
            paramsObj.put("buyer_id", memberId);
            paramsObj.put("seller_id", seller_id);
            paramsObj.put("out_trade_body", paramsObj.toString());
        } catch (JSONException e) {
            e.printStackTrace();
        }
        if (paramsObj.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsObj.toString());
        params.put("service", "finance.orderPay");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/finance", requestId, params);
    }

    /**
     * 确认订单
     *
     * @param order_id          订单号
     * @param external_order_no 淘宝订单号
     */
    public void requestOrderConfirm(int requestId, String order_id, String external_order_no) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject paramsObj = new JSONObject();
        try {
            paramsObj.put("data_source", "SJLY_02");
            paramsObj.put("order_id", order_id);
            paramsObj.put("external_order_no", external_order_no);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        if (paramsObj.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsObj.toString());
        params.put("service", "order.fgOrderConfirm");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/opsorder", requestId, params);
    }

    /**
     * 取消订单
     *
     * @param order_id          订单号
     * @param external_order_no 淘宝订单号
     */
    public void requestOrderCancle(int requestId, String order_id, String external_order_no) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);

        params.put("service", "order.fgOrderCancelled");

        Map<String, String> map = new HashMap<>();
        map.put("remark", external_order_no);
        map.put("order_id", order_id);
        map.put("data_source", "SJLY_02");
        params.put("params", new Gson().toJson(map));
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/opsorder", requestId, params);
    }

    /**
     * 新任务详情页面
     *
     * @param task_id   任务id
     */
    public void requestNewTaskDetails(int requestId, String task_id) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject paramsObj = new JSONObject();
        try {
            paramsObj.put("member_id", MainActivity.member_id);
            paramsObj.put("member_type_key", SettingData.STORES);
            paramsObj.put("task_id", task_id);
        } catch (Exception e) {
        }
        if (paramsObj.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsObj.toString());
        params.put("service", "odTask.stores.odTaskDetailFind");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/opsorder", requestId, params);
    }

    /**
     * 日志查询
     */
    public void requestLogList(int requestId, String processing_id) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject paramsObj = new JSONObject();
        try {
//            paramsObj.put("member_id", MainActivity.member_id);
//            paramsObj.put("member_type_key", SettingData.STORES);
            paramsObj.put("processing_id", processing_id);
        } catch (Exception e) {
        }
        if (paramsObj.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsObj.toString());
        params.put("service", "odTask.app.odTaskProcessingLogListPageFind");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/opsorder", requestId, params);
    }

    /**
     * 子任务详情
     */
    public void requestSubTaskDetails(int requestId, String processing_id) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject paramsObj = new JSONObject();
        try {
            paramsObj.put("member_id", MainActivity.member_id);
            paramsObj.put("member_type_key", SettingData.STORES);
            paramsObj.put("processing_id", processing_id);
        } catch (Exception e) {
        }
        if (paramsObj.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsObj.toString());
        params.put("service", "odTask.stores.odTaskProcessingDetailFind");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/opsorder", requestId, params);
    }

    /**
     * 提交任务
     */
    public void requestTaskProcessingSubmit(int requestId, String processing_id, String json_data) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject paramsObj = new JSONObject();
        try {
            paramsObj.put("member_id", MainActivity.member_id);
            paramsObj.put("member_type_key", SettingData.STORES);
            paramsObj.put("processing_id", processing_id);
            paramsObj.put("json_data", json_data);
        } catch (Exception e) {
        }
        if (paramsObj.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsObj.toString());
        params.put("service", "odTask.stores.odTaskProcessingSubmit");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/opsorder", requestId, params);
    }

    /**
     * 参加任务
     */
    public void requestJoinTask(int requestId, String task_id, String loginPhone) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject paramsObj = new JSONObject();
        try {
            paramsObj.put("member_id", MainActivity.member_id);
            paramsObj.put("member_type_key", SettingData.STORES);
            paramsObj.put("member_name", Stores.stores_name);
            paramsObj.put("member_mobile", loginPhone);
            paramsObj.put("task_id", task_id);
        } catch (Exception e) {
        }
        if (paramsObj.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsObj.toString());
        params.put("service", "odTask.stores.odTaskJoin");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/opsorder", requestId, params);
    }

    /**
     * 任务数统计
     */
    public void requestTaskNumber(int requestId) {
        if (TextUtils.isEmpty(Stores.area_id)) {
            return;
        }
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject paramsObj = new JSONObject();
        try {
            paramsObj.put("member_id", MainActivity.member_id);
            paramsObj.put("member_type_key", SettingData.STORES);
            paramsObj.put("area_id", Stores.area_id);

        } catch (Exception e) {
        }
        if (paramsObj.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsObj.toString());
        params.put("service", "odTask.stores.odTaskNewCountForStoresFind");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/opsorder", requestId, params);
    }

    /**
     * @param rebate_cash     返现
     * @param reward_gold     送金币
     * @param flow_no         有二维码能取到时候就取，没有则用工具类生成
     * @param amount          原始金额
     * @param dikou           折扣金额
     * @param cash_dealing    实付金额
     * @param payment_way_key 支付方式
     * @param reduce_amount   减免
     */
    public void requestCommitRecord(int requestId, String rebate_cash, String reward_gold, String flow_no, String amount, String dikou, String reduce_amount, String cash_dealing, String payment_way_key) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject paramsObj = new JSONObject();
        try {
            paramsObj.put("flow_no", flow_no);//交易号
            paramsObj.put("rebate_cash", rebate_cash);
            paramsObj.put("reward_gold", reward_gold);
            paramsObj.put("stores_id", MainActivity.member_id);
            paramsObj.put("amount", amount + "");//金额
            paramsObj.put("discount_amount", dikou + "");    //抵扣
            paramsObj.put("pay_amount", cash_dealing + "");
            paramsObj.put("reduce_amount", reduce_amount + "");
//            if (TextUtils.isEmpty(LocationApplication.userId)) {
//                LocationApplication.userId = MainActivity.member_id;//如果取不到值的情况
//            }
            paramsObj.put("cashier_id", LocationApplication.userId);   //登录时获取
            paramsObj.put("payment_way_key", payment_way_key);   //收银方式
        } catch (Exception e) {
        }
        if (paramsObj.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsObj.toString());
        params.put("service", "finance.storesCashierCreate");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/finance", requestId, params);
    }




    /**
     * 发货
     */
    public void requestOrderDeliver(int requestId, String order_id) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject paramsObj = new JSONObject();
        try {
            paramsObj.put("order_id", order_id);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        if (paramsObj.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsObj.toString());
        params.put("service", "order.pcOrderDeliver");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/opsorder", requestId, params);
    }

    /**
     * 便利店订单取消
     */
    public void requestOrderCancel(int requestId, String order_id) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject paramsObj = new JSONObject();
        try {
            paramsObj.put("order_id", order_id);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        if (paramsObj.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsObj.toString());
        params.put("service", "order.pcOrderCancelled");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/opsorder", requestId, params);
    }

    /**
     * 伙拼团订单取消
     *
     * @param remark    取消理由
     */
    public void requestHPTOrderCancel(int requestId, String order_id, String remark) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject paramsObj = new JSONObject();
        try {
            paramsObj.put("order_id", order_id);
            paramsObj.put("data_source", "SJLY_02");
            paramsObj.put("remark", remark);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        if (paramsObj.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsObj.toString());
        params.put("service", "order.psOrderCancelled");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/opsorder", requestId, params);
    }

    /**
     * 确认收货
     */
    public void requestOrderReceived(int requestId, String order_id) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        JSONObject paramsObj = new JSONObject();
        try {
            paramsObj.put("order_id", order_id);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        if (paramsObj.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsObj.toString());
        params.put("service", "order.psOrderReceived");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/opsorder", requestId, params);
    }

    /**
     * 获取我要批详情
     */
    public void requestGoodDetail(int requestId, String order_id, String area_id) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);

        JSONObject paramsObj = new JSONObject();
        try {
            paramsObj.put("goods_id", order_id);
            paramsObj.put("area_id", area_id);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        Log.v("zyl", "paramsObj.toString():" + paramsObj.toString());
        if (paramsObj.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsObj.toString());
        params.put("service", "goods.psGoodsDetailFind");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/goods", requestId, params);
    }

    /**
     * 通过sku_code查询优惠券信息
     */
    public void requestCouponValidateFindForStores(int requestId, String sku_code) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);

        JSONObject paramsObj = new JSONObject();
        try {
            paramsObj.put("sku_code", sku_code);
            paramsObj.put("member_id", MainActivity.member_id);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        Log.v("zyl", "paramsObj.toString():" + paramsObj.toString());
        if (paramsObj.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsObj.toString());
        params.put("service", "goods.couponValidateFindForStores");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/goods", requestId, params);
    }

    /**
     * 一元抽奖活动查询
     */
    public void requestActivityValidateFind(int requestId, String activity_type, String activity_id) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);

        JSONObject paramsObj = new JSONObject();
        try {
            paramsObj.put("activity_type", activity_type);
            paramsObj.put("stores_id", MainActivity.member_id);
            paramsObj.put("activity_id", activity_id);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        Log.v("zyl", "paramsObj.toString():" + paramsObj.toString());
        if (paramsObj.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsObj.toString());
        params.put("service", "goods.ldActivityValidateFind");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/goods", requestId, params);
    }

    /**
     * 创建刮刮乐活动
     */
    public void requestCreateActivityGGL(int requestId, String title, String award_name, String award_value, String award_pic_path1) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);

        JSONObject paramsObj = new JSONObject();
        try {
            paramsObj.put("stores_id", MainActivity.member_id);
            paramsObj.put("title", title);
            paramsObj.put("award_name", award_name);
            paramsObj.put("award_value", award_value);
            paramsObj.put("award_pic_path1", award_pic_path1);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        if (paramsObj.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsObj.toString());
        params.put("service", "goods.ldGglActivityCreate");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/goods", requestId, params);
    }

    /**
     * 创建摇一摇活动
     */
    public void requestCreateActivityYYY(int requestId, String title, String award_name, String award_value, String award_pic_path1) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);

        JSONObject paramsObj = new JSONObject();
        try {
            paramsObj.put("stores_id", MainActivity.member_id);
            paramsObj.put("title", title);
            paramsObj.put("award_name", award_name);
            paramsObj.put("award_value", award_value);
            paramsObj.put("award_pic_path1", award_pic_path1);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        if (paramsObj.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsObj.toString());
        params.put("service", "goods.ldYyyActivityCreate");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/goods", requestId, params);
    }

    /**
     * 礼券订单取消
     */
    public void requestLeOrderCancel(int requestId, String order_id) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);

        JSONObject paramsObj = new JSONObject();
        try {
            paramsObj.put("data_source", "SJLY_02");
            paramsObj.put("order_id", order_id);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        if (paramsObj.toString().equals("{}")) {
            return;
        }
        params.put("params", paramsObj.toString());
        params.put("service", "order.leOrderCancelled");
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/opsorder", requestId, params);
    }


    public String genPackageSignUser(AjaxParams params) {
        if (context != null) {
            if (TextUtils.isEmpty(MainActivity.user_security_code)) {
                SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
                MainActivity.user_security_code = preferences.getString("user_security_code", "");
//                ToastUtils.showTextToast(context,"user_security_code丢失");
            }
        }
        String paramString = params.toString();
        List<String> sortList = new ArrayList<>();
//        Log.v("zyl", "加密前：" + paramString);
        String[] arrs = paramString.split("&");
        for (int i = 0; i < arrs.length; i++) {
            sortList.add(arrs[i] + "&");
        }
        Collections.sort(sortList, Collator.getInstance(java.util.Locale.CHINA));
        String signStr = "";
        for (String s : sortList) {
            signStr += s;
        }
        signStr = signStr.toString().substring(0, signStr.toString().length() - 1);
        signStr += MainActivity.user_security_code;
//        Log.v("zyl","MainActivity.user_security_cod："+MainActivity.user_security_code);
//        Log.v("zyl","加密前2："+signStr);

        String packageSign = MD5.getMessageDigest(signStr.getBytes());
        return packageSign;
    }

    public String genPackageSign(AjaxParams params) {

        String paramString = params.toString();
//        Log.v("zyl", "paramString:" + paramString);
        List<String> sortList = new ArrayList<>();
//        Log.v("zyl", "排序前的签名：" + paramString);
        String[] arrs = paramString.split("&");
        for (int i = 0; i < arrs.length; i++) {
            sortList.add(arrs[i] + "&");
        }
        Collections.sort(sortList, Collator.getInstance(java.util.Locale.CHINA));
        String signStr = "";
        for (String s : sortList) {
            signStr += s;
        }
//        Log.v("zyl", "剪切前：" + signStr);
        signStr = signStr.toString().substring(0, signStr.toString().length() - 1);
        signStr += MainActivity.security_code;
        String packageSign = MD5.getMessageDigest(signStr.getBytes());
//        Log.v("zyl", "排序后的签名：" + packageSign);
        return packageSign;
    }

    /**
     * 发送设置的alias，极光推送
     */
    public void requestJpush(int requestId, String stores, String android, String alias) {

        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        params.put("member_type_key", stores);
        params.put("data_source", SettingData.DATA_SOURCE);
        params.put("device_type", android);
        params.put("device_model", TestDeviveInfo.getDeviceInfo() + "");
        params.put("alias", alias);
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/user/login_log_update", requestId, params);
    }

    public void requestUploadPic(int requestId, InputStream inputStream) {
        AjaxParams params = new AjaxParams();
        if (TextUtils.isEmpty(MainActivity.app_token)) {
            SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(context);
            MainActivity.app_token = preferences.getString("app_token", "");
        }
        Log.v("zyl", " requestUploadPic  MainActivity.app_token:" + MainActivity.app_token);
        params.put("app_token", MainActivity.app_token);
        params.put("category", "oss_community");
        params.put("subffix", "jpg");
        if(inputStream==null){
            Log.v("zyl","inputStream==null");
        }else{
            // Adds content-type of JPEG.
            params.put("up_load_file", inputStream, "pic.jpg", "image/jpeg");
            requestDataUploadPic(requestId, params);
        }
    }

    //获取火拼团详情
    public void requestHtpDetails(int requestId, String s_activity_id) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        params.put("service", "tsActivity.stores.tsActivityDetail");
        JSONObject paramsObj = new JSONObject();
        try {
            paramsObj.put("activity_id", s_activity_id);
        } catch (JSONException e) {
            e.printStackTrace();
        }
        params.put("params", paramsObj.toString());
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/opsorder", requestId, params);
    }

    //获取参与人
    public void getJsonPerson(int requestId, String s_activity_id) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        params.put("service", "tsOrder.stores.tsOrderListPageFind");
        JSONObject paramsObj = new JSONObject(); //activity_id
        try {
            paramsObj.put("activity_id", s_activity_id);


        } catch (JSONException e) {
            e.printStackTrace();
        }
        params.put("params", paramsObj.toString());
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/opsorder", requestId, params);
    }

    //获取火拼团列表
    public void getHptOrder(int requestId, int pageNum, int pageSize) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        params.put("service", "tsActivity.stores.tsActivityListPageFind");
        JSONObject paramsObj = new JSONObject(); //activity_id
        JSONObject paramsObj2 = new JSONObject();//page
        try {
            paramsObj.put("stores_id", MainActivity.member_id);

            paramsObj2.put("page_size", pageSize + "");
            paramsObj2.put("page_no", pageNum + "");
        } catch (JSONException e) {
            e.printStackTrace();
        }
        params.put("params", paramsObj.toString());
        params.put("page", paramsObj2.toString());
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/opsorder", requestId, params);
    }

    //火拼团确认收货
    public void getHptconfirmOrder(int requestId, String activity_id) {
        AjaxParams params = new AjaxParams();
        params.put("user_token", MainActivity.user_token);
        params.put("service", "tsActivity.stores.tsActivityReceived");
        JSONObject paramsObj = new JSONObject(); //activity_id
        try {
            paramsObj.put("activity_id", activity_id);

        } catch (JSONException e) {
            e.printStackTrace();
        }
        params.put("params", paramsObj.toString());
        params.put("sign", genPackageSignUser(params));
        requestData("/openapi/opsorder", requestId, params);
    }
}
